how to show/hide comments in visual studio 2019 - visual-studio

How can i hide/show comments on visual studio 2019 i tried the extention 'HideShow Comments' but i did not work work with the version 2019 of vs
somethink like this :
comments activated :
/// <summary>
/// Syncroniously reads specified number of ushorts starting from specified address in data memory
/// </summary>
/// <param name="startAddress">Address to start to read from</param>
/// <param name="count">Number of ushorts to read</param>
/// <returns>Read data</returns>
public ushort[] ReadData(ushort startAddress, ushort count)
{
var sid = IncrementSid();
var cmd = FinsDriver.ReadDataCommand(new Header(sid, true), startAddress, count);
return Read(sid, cmd);
}
and comments disabled :
public ushort[] ReadData(ushort startAddress, ushort count)
{
var sid = IncrementSid();
var cmd = FinsDriver.ReadDataCommand(new Header(sid, true), startAddress, count);
return Read(sid, cmd);
}

There are some VS extensions that might do what you want.
NoComment - hides comments and replaces them with a callout icon. Comments are shown as tooltip and when editing them.
CommentsRemover - removes both single line and multi-line comments from current active document/project/solution while preserving documentation headers (File header, Class headers & method headers) and those.
Collapse Comments - adds a command to collapse comments in the open code file.

Related

Azure Media Services v3 - Preset for generating captions: Azure Media Indexer 2 Preview

Is there a Preset for generating captions like the v2 Azure Media Indexer 2 Preview media processor, found in V2?
Hypothetical example:
var transform = await _client.Transforms.GetAsync(ResourceGroup, AccountName, TranscribeTransformName);
if (transform == null)
{
var output = new[]
{
new TransformOutput
{
Preset = new BuiltInMediaIndexerPreset
{
PresetName = "Azure Media Indexer 2 Preview"
}
}
};
Found the solution by examining the code comments from Go To References.
var transform = await _client.Transforms.GetAsync(ResourceGroup, AccountName, TranscribeTransformName);
if (transform == null)
{
var output = new[]
{
new TransformOutput(new VideoAnalyzerPreset("en-US", InsightsType.AudioInsightsOnly))
};
transform = await _client.Transforms.CreateOrUpdateAsync(ResourceGroup, AccountName, TranscribeTransformName, output);
}
/// <summary>
/// Initializes a new instance of the VideoAnalyzerPreset class.
/// </summary>
/// <param name="audioLanguage">The language for the audio payload in
/// the input using the BCP-47 format of 'language tag-region' (e.g:
/// 'en-US'). The list of supported languages are, 'en-US', 'en-GB',
/// 'es-ES', 'es-MX', 'fr-FR', 'it-IT', 'ja-JP', 'pt-BR', 'zh-CN',
/// 'de-DE', 'ar-EG', 'ru-RU', 'hi-IN'. If not specified, automatic
/// language detection would be employed. This feature currently
/// supports English, Chinese, French, German, Italian, Japanese,
/// Spanish, Russian, and Portuguese. The automatic detection works
/// best with audio recordings with clearly discernable speech. If
/// automatic detection fails to find the language, transcription would
/// fallback to English.</param>
/// <param name="insightsToExtract">The type of insights to be
/// extracted. If not set then based on the content the type will
/// selected. If the content is audi only then only audio insights are
/// extraced and if it is video only. Possible values include:
/// 'AudioInsightsOnly', 'VideoInsightsOnly', 'AllInsights'</param>
public VideoAnalyzerPreset(string audioLanguage = null, InsightsType? insightsToExtract = null);
Does captioning work for videos encoded with "AdaptiveStreaming" as well?

How to Automate SharePoint Record Updates

So we have an inventory list with details about each item, mostly drop down menus and check boxes, some comments and descriptions. These records are in SharePoint. Sometimes we need to update multiple items in there in addition to a large number of other steps and I am trying to automate most of these steps including the updates to their SharePoint record. What is the best way to go about this in PowerShell from any remote computer?
Would I connect to the database, find the record and and update the record there? Is there an easier way? I tried finding PowerShell CLI tools for SharePoint but I don't see them available anywhere.
For example, I might want to update this field here:
I think the the best Automate update list item in SharePoint remotely is using CSOM(C# code) API.
Here is a demo about update list item for your reference:
// Starting with ClientContext, the constructor requires a URL to the
// server running SharePoint.
ClientContext context = new ClientContext("http://SiteUrl");
// Assume that the web has a list named "Announcements".
List announcementsList = context.Web.Lists.GetByTitle("Announcements");
// Assume there is a list item with ID=1.
ListItem listItem = announcementsList.GetItemById(1);
// Write a new value to the Body field of the Announcement item.
listItem["Body"] = "This is my new value!!";
listItem.Update();
context.ExecuteQuery();
For do authentication to access SharePoint, we can do as below:
/// <summary>
/// set authentication of SharePoint online
/// </summary>
/// <param name="clientContext"></param>
/// <param name="userName"></param>
/// <param name="password"></param>
public static void setOnlineCredential(ClientContext clientContext,string userName,string password)
{
//set the user name and password
SecureString secureString = new SecureString();
foreach (char c in password.ToCharArray())
{
secureString.AppendChar(c);
}
clientContext.Credentials = new SharePointOnlineCredentials(userName, secureString);
}
/// <summary>
/// set authentication of SharePoint on-premise
/// </summary>
/// <param name="clientContext"></param>
/// <param name="userName"></param>
/// <param name="password"></param>
/// <param name="domain"></param>
public static void setClientCredential(ClientContext clientContext, string userName, string password, string domain)
{
clientContext.Credentials = new NetworkCredential(userName, password, domain);
}
If you want to use PowerShell, We can use PowerShell to use CSOM as this article talked: CSOM SharePoint PowerShell Reference and Example Codes and we just need to modify the code above to be PowerShell code

Enabling documentation within WebApi2 help page

I have a simple webapi2 project.
The only information I can seem to find myself refers to the older webapi1
From my controller if I have
/// <summary>
/// Gets a list of not very interesting information
/// </summary>
/// <returns>The list</returns>
[ResponseType(typeof(ExampleModel))]
public IHttpActionResult Get()
{
var data = new List<ExampleModel>()
{
new ExampleModel()
{
Date = DateTime.Now,
Name = "Tom"
},
new ExampleModel()
{
Date = DateTime.Now.AddDays(-20),
Name = "Bob"
}
};
why is no information appearing when I try browse to the help page. I am told No documentation available.
Is there a magic switch somewhere that will turn on automated population of this data?
if you referring to displaying the xml comments, then you can find my answer here:
ASP.NET Web API Help Page documentation using Xml comments on controllers
Be sure to uncomment this code in Areas/HelpPage/App_Start/HelpPageConfig.cs
// Uncomment the following to use the documentation from XML documentation file.
config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml")));
Also make sure the xml file goes in App_Data not bin where it defaults to in project properties

Windows azure blob storage from a SQL SSIS package

Is it possible to upload images to Windows azure blob storage from a SQL SSIS package? SSIS will read new images (on daily basis) from one of my on-Premise SQL Server (table) and upload images to blob storage.
What a fun question this was! I got to thread together a lot of pieces that I had never tried.
I first built out a simple console app based on the fine manual over on HOW TO: Blob Storage. Knowing that I had working code allowed me to adapt it for SSIS.
I created 3 SSIS Variables at the Package level. AccountName, AccountKey and ContainerName. They are all data type String. These provide credentials + the folder where my uploaded data will reside.
Data Flow
The general look of your data flow is rather simple. A data source to a Script Component that will act as a Destination. You will need two columns: one provides a unique name for the blob and the other will be the binary bits.
My source is a trivial table. It has Country Names and their flag (stored as varbinary(max)) which you yourself can scrape from the CIA World Handbook if you're so inclined.
The Destination will be a bit of C#. Add a Script Component of type Destination.
On the Script tab, I have 3 ReadOnly Variables listed User::AccountKey,User::AccountName,User::ContainerName
On the Input Columns tab, I select CountryName and FlagImage.
The script itself follows. As noted in the How To, you will need to add a reference to Microsoft.WindowsAzure.Storage assembly before you can access the last 3 assemblies there.
using System;
using System.Data;
using System.IO;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
// Must add reference to Microsoft.WindowsAzure.Storage for this to work
// http://www.windowsazure.com/en-us/develop/net/how-to-guides/blob-storage/
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Auth;
using Microsoft.WindowsAzure.Storage.Blob;
/// <summary>
/// Watch me load data to Azure from SSIS
/// </summary>
[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{
/// <summary>
/// The storage account used
/// </summary>
private CloudStorageAccount storageAccount;
/// <summary>
/// An entity to work with the Blobs
/// </summary>
private CloudBlobClient blobClient;
/// <summary>
/// Blobs live in containers
/// </summary>
private CloudBlobContainer container;
/// <summary>
/// blockBlob instead of a pageBlob
/// </summary>
private CloudBlockBlob blockBlob;
/// <summary>
/// This method is called once, before rows begin to be processed in the data flow.
///
/// You can remove this method if you don't need to do anything here.
/// </summary>
public override void PreExecute()
{
base.PreExecute();
string cs = string.Empty;
string csTemplate = string.Empty;
string accountName = string.Empty;
string accountKey = string.Empty;
string containerName = string.Empty;
accountName = Variables.AccountName;
accountKey = Variables.AccountKey;
containerName = Variables.ContainerName;
csTemplate = "DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}";
cs = string.Format(csTemplate, accountName, accountKey);
this.storageAccount = CloudStorageAccount.Parse(cs);
this.blobClient = this.storageAccount.CreateCloudBlobClient();
this.container = this.blobClient.GetContainerReference(containerName);
this.container.CreateIfNotExists();
this.container.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob });
}
/// <summary>
/// For each row passing through, upload to Azure
/// </summary>
/// <param name="Row">The row that is currently passing through the component</param>
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
string blobName = string.Empty;
using (MemoryStream memStream = new MemoryStream(Row.FlagImage.GetBlobData(0, (int)Row.FlagImage.Length)))
{
this.blockBlob = this.container.GetBlockBlobReference(Row.CountryName);
this.blockBlob.UploadFromStream(memStream);
}
}
}
Global Assembly Cache (GAC)
Assemblies you wish to use within SSIS must reside in the GAC. Assemblies cannot go into the GAC unless they are signed. Fortunately, the Azure assemblies are signed so from a Visual Studio Command Prompt, type gacutil -if "C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\v2.1\ref\Microsoft.WindowsAzure.Storage.dll" or the equivalent of where your version of that assembly exists
Load successful
And as proof, here's a shot from Azure Storage Explorer
SSIS 2012 and above now have a Microsoft-supported task to upload/download data to Azure Storage:
Example. "Microsoft SQL Server 2016 Integration Services Feature Pack for Azure": https://www.microsoft.com/en-us/download/details.aspx?id=49492
just search for 2012 and 2014 if that's what you are using.
Hope that helps!

Play MP3 using Media with phonegap/Cordova

My problem:
I use the Media Class from Cordova.
The MP3 file is only played once (the first time).
Code:
Add this code to the Cordova Starter project to reproduce my problem:
var playCounter = 0;
function playMP3(){
console.log("playMP3() counter " + playCounter);
var my_media = new Media("app/www/test.mp3");//ressource buildAction == content
my_media.play();
playCounter++;
}
[...]
<p onclick="playMP3();">Click to Play MP3</p>
VS output:
[...]
GapBrowser_Navigated :: /app/www/index.html
'UI Task' (Managed): Loaded 'System.ServiceModel.Web.dll'
'UI Task' (Managed): Loaded 'System.ServiceModel.dll'
Log:"onDeviceReady. You should see this message in Visual Studio's output window."
'UI Task' (Managed): Loaded 'Microsoft.Xna.Framework.dll'
Log:"playMP3() counter 0"
'UI Task' (Managed): Loaded 'System.SR.dll'
Log:"media on status :: {\"id\": \"fa123123-bc55-a266-f447-8881bd32e2aa\", \"msg\": 1, \"value\": 1}"
A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll
Log:"media on status :: {\"id\": \"fa123123-bc55-a266-f447-8881bd32e2aa\", \"msg\": 1, \"value\": 2}"
Log:"media on status :: {\"id\": \"fa123123-bc55-a266-f447-8881bd32e2aa\", \"msg\": 2, \"value\": 2.141}"
Log:"media on status :: {\"id\": \"fa123123-bc55-a266-f447-8881bd32e2aa\", \"msg\": 1, \"value\": 4}"
Log:"playMP3() counter 1"
A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.IOException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.IsolatedStorage.IsolatedStorageException' occurred in mscorlib.dll
Log:"media on status :: {\"id\": \"2de3388c-bbb6-d896-9e27-660f1402bc2a\", \"msg\": 9, \"value\": 5}"
My Config:
cordova-1.6.1.js
Lumia 800
WP 7.5 (7.10.7740.16)
WorkAround (kind of):
Desactivate the app (turn off the screen)
reactivate the app (turn on the screen)
-> you get one more shot.
Any help is welcome as I am blocked on this since may days and I found no usefull information anywhere.
Also, Can you tell me if this code work on your config ?
.
.
.
Update: add a demo code, Cordova 1.8.0rc1
using a global var. Keeping the instance alive.
result
The test2.mp3 is played and can replay fine.
the test.mp3 is not played at all.
It is the first file you play that will work.
Code
function onDeviceReady()
{
document.getElementById("welcomeMsg").innerHTML += "Cordova is ready! version=" + window.device.cordova;
console.log("onDeviceReady. You should see this message in Visual Studio's output window.");
my_media = new Media("app/www/test.mp3");//ressource buildAction == content
my_media2 = new Media("app/www/test2.mp3");//ressource buildAction == content
}
var playCounter = 0;
var my_media = null;
function playMP3(){
console.log("playMP3() counter " + playCounter);
my_media.play();
playCounter++;
}
var my_media2 = null;
function playMP32(){
console.log("playMP32() counter " + playCounter);
my_media2.play();
playCounter++;
}
</script>
[...]
<p onclick="playMP3();">Click to Play MP3</p>
<p onclick="playMP32();">Click to Play MP3 2</p>
VS output:
Log:"onDeviceReady. You should see this message in Visual Studio's output window."
INFO: startPlayingAudio could not find mediaPlayer for 71888b14-86fe-4769-95c9-a9bb05d5555b
Log:"playMP32() counter 0"
INFO: startPlayingAudio could not find mediaPlayer for 71888b14-86fe-4769-95c9-a9bb05d5555b
Log:"playMP32() counter 1"
Log:"playMP3() counter 2"
INFO: startPlayingAudio could not find mediaPlayer for b60fa266-d105-a295-a5be-fa2c6b824bc1
A first chance exception of type 'System.ArgumentException' occurred in System.Windows.dll
Error: El parĂ¡metro es incorrecto.
Log:"playMP32() counter 3"
INFO: startPlayingAudio could not find mediaPlayer for 71888b14-86fe-4769-95c9-a9bb05d5555b
.
.
.
Update: Cordova 2.0.0
I upated the Apache bug report with a test case for 2.0.0.
Can anybody reproduce this ?
link to bug report:
https://issues.apache.org/jira/browse/CB-941
I see you are getting an IsolatedStorageException on the second click, which makes me think the file is being held open by the first Media instance which prevents it from being accessed again.
I suggest ensuring that you either only create one instance of Media per file or see if there is a way to dispose of the old instance first.
Here is what I would try (but I haven't tested):
var playCounter = 0;
// moved my_media here so it won't be recreated
var my_media = new Media("app/www/test.mp3");//ressource buildAction == content
function playMP3(){
console.log("playMP3() counter " + playCounter);
my_media.play();
playCounter++;
}
[...]
<p onclick="playMP3();">Click to Play MP3</p>
almost forgot ... this works for my purposes. Hope it helps ;-)
WP7.5/Cordova 1.9.0
REQUIREMENT: Only works with .wav files as far as I know. I had to convert my .mp3 files, as they throw ugly exceptions.
PLUGIN:C#:
namespace Cordova.Extension.Commands
{
public class PGSoundFX : BaseCommand
{
public Dictionary <string, SoundEffect> fxSoundMap = new Dictionary<string,SoundEffect>();
public enum FXType
{
Load=0,
Play=1
}
[DataContract]
public class FXOption
{
[DataMember]
public string audioSrc;
[DataMember]
public string audioRef;
[DataMember]
public FXType fxType;
}
public void groAudio(string options)
{
FrameworkDispatcher.Update();
FXOption opts;
opts = WP7CordovaClassLib.Cordova.JSON.JsonHelper.Deserialize<FXOption>(options);
if (opts != null)
{
try
{
switch (opts.fxType)
{
case FXType.Load:
loadSound(opts.audioSrc, opts.audioRef);
break;
case FXType.Play:
Dictionary<string, SoundEffect>.KeyCollection keyCol = fxSoundMap.Keys;
foreach (string tmp in keyCol)
{
if ((opts.audioRef).Equals(tmp))
playSound(fxSoundMap[tmp]);
}
break;
}
}
catch
{
Debug.WriteLine("PGSoundFX: loadSound Error ... null parameter(s).");
}
}
}
/// <summary>
/// Loads a wav file into an XNA Framework SoundEffect.
/// </summary>
/// <param name="Sound">The SoundEffect to play.</param>
private void playSound(SoundEffect Sound)
{
Sound.Play();
DispatchCommandResult(new PluginResult(PluginResult.Status.OK));
}
/// <summary>
/// Loads a wav file into an XNA Framework SoundEffect.
/// </summary>
/// <param name="SoundFilePath">Relative path to the wav file.</param>
/// <param name="Sound">The SoundEffect to load the audio into.</param>
private void loadSound(String SoundFilePath, String SoundName)
{
if (fxSoundMap.Keys != null)
{
Dictionary<string, SoundEffect>.KeyCollection keyColl = fxSoundMap.Keys;
foreach (string tmp in keyColl)
{
if (SoundName.Equals(tmp))
return;
}
}
SoundEffect Sound = null;
try
{
// Holds informations about a file stream.
StreamResourceInfo SoundFileInfo = Application.GetResourceStream(new Uri(SoundFilePath, UriKind.Relative));
// Create the SoundEffect from the Stream
Sound = SoundEffect.FromStream(SoundFileInfo.Stream);
fxSoundMap[SoundName] = Sound;
DispatchCommandResult(new PluginResult(PluginResult.Status.OK));
}
catch (NullReferenceException)
{
Debug.WriteLine("Couldn't load sound " + SoundFilePath);
}
}
}
}
Javascript:Plugin:
PhoneGap.addConstructor(function() {
navigator.plugins.pgSoundFX =
{
playSound:function(fxName)
{
var options = {"audioRef":fxName,"fxType":1};
PhoneGap.exec(null, null, "PGSoundFX", "groAudio", options);
},
loadSound:function(fxSrc, fxName)
{
var options = {"audioSrc":fxSrc,"audioRef":fxName,"fxType":0};
PhoneGap.exec(null, null, "PGSoundFX", "groAudio", options);
}
}
});
Javascript:Use:
//NOTE: Allows you to pre-load sound effect files
//initialize pgSoundFX plugin
if (!navigator.plugins) {
console.log("plugIns do not exist!");
navigator.plugins = {};
}
navigator.plugins.pgSoundFX.loadSound("www/audio/file1.wav", "item1");
navigator.plugins.pgSoundFX.loadSound("www/audio/file2.wav", "item2");
navigator.plugins.pgSoundFX.loadSound("www/audio/file3.wav", "item3");
:
:
//NOTE: Play whenever needed
navigator.plugins.pgSoundFX.playSound("item1");
Of course, your file location (www/audio/), names (file1, etc.) and reference names (item1, etc) are whatever you want. As with most, lots of ways to improve this code...feel free. My use case pre-loads five .wav files ranging in size from 28k - 364k and plays them throughout user game play.
I am not sure it is the correct answer as I did not try it but consider it as a brain storming.
first create your audio with var my_media = new Media(src, onSuccess, onError); ctor and on success just play it and on error first try to release it with media.release code.
Well if you know some other event or action to release it would be more appropriate.
Edit : I just noticed it, you are not using stop for media you can also try to use it when it is needed for example beginning of the playMP3() if media is not null try to stop it first.
Cheers.
I think the issue may be with the limitation that Silverlight only allows one media instance per page...and since PG/Cordova is essentially a single-page webBrowser instance, it can only have one media instance. I am playing around with building an XNA SoundEffect plugin to get around this issue.
was a Cordova bug
https://issues.apache.org/jira/browse/CB-941
solved by purpulecabbage in his repo of gitHub. see comment on bug report.

Resources