Solution
Namespace:
Microsoft.Azure.Management.AppService.Fluent
We found 10 examples in language CSharp for this search.
You will see 58 fragments of code.
Other methods
Other methods
Project:cs-optimization-continuous-solutions
File:NelderMeadMethod.cs
Examples:6
public override ContinuousSolution Minimize(double[] x_0, CostEvaluationMethod evaluate, GradientEvaluationMethod calc_gradient, TerminationEvaluationMethod should_terminate, object constraints = null)
{
ContinuousSolution best_solution = new ContinuousSolution();
int dimension = x_0.Length;
int vertex_count = dimension + 1;
double[] x = (double[])x_0.Clone();
List<ContinuousSolution> solutions = new List<ContinuousSolution>();
for (int i = 0; i < vertex_count; ++i)
{
double[] temp = (double[])x_0.Clone();
if (i == vertex_count - 1)
{
temp[0] -= 1.0;
}
else
{
temp[i] += 1.0;
}
solutions.Add(new ContinuousSolution(temp, evaluate(temp, mLowerBounds, mUpperBounds, constraints)));
}
ContinuousSolution centroid = new ContinuousSolution();
double? improvement = null;
int iteration = 0;
while (!should_terminate(improvement, iteration))
{
Sort(solutions);
CalculateCentroid(solutions, centroid);
double[] x_r;
Reflect(solutions, centroid, mAlpha, out x_r);
double fx_r = evaluate(x_r, mLowerBounds, mUpperBounds, constraints);
if (fx_r >= solutions[0].Cost && fx_r < solutions[solutions.Count - 2].Cost)
{
ContinuousSolution last_solution = solutions[solutions.Count - 1];
last_solution.Values = x_r;
last_solution.Cost = fx_r;
}
else if (fx_r < solutions[0].Cost)
{
double[] x_e;
Expand(solutions, centroid, mGamma, out x_e);
double fx_e = evaluate(x_e, mLowerBounds, mUpperBounds, constraints);
if (fx_e < fx_r)
{
ContinuousSolution last_solution = solutions[solutions.Count - 1];
last_solution.Values = x_e;
last_solution.Cost = fx_e;
}
else
{
ContinuousSolution last_solution = solutions[solutions.Count - 1];
last_solution.Values = x_r;
last_solution.Cost = fx_r;
}
}
else
{
double[] x_c;
Contract(solutions, centroid, mRho, out x_c);
double fx_c = evaluate(x_c, mLowerBounds, mUpperBounds, constraints);
if (fx_c < solutions[solutions.Count - 1].Cost)
{
ContinuousSolution last_solution = solutions[solutions.Count - 1];
last_solution.Values = x_c;
last_solution.Cost = fx_c;
}
else
{
Reduce(solutions, mSigma);
int solution_count = solutions.Count;
for (int i = 1; i < solution_count; ++i)
{
ContinuousSolution s = solutions[i];
s.Cost = evaluate(s.Values, mLowerBounds, mUpperBounds, constraints);
}
}
}
if (best_solution.TryUpdateSolution(solutions[0].Values, solutions[0].Cost, out improvement))
{
OnSolutionUpdated(best_solution, iteration);
}
OnStepped(solutions[0], iteration);
iteration++;
}
return best_solution;
}
public void Reduce(List<ContinuousSolution> solutions, double sigma)
{
int solution_count = solutions.Count;
ContinuousSolution best_solution = solutions[0];
double[] x_0 = best_solution.Values;
int dimension = x_0.Length;
for (int i = 1; i < solution_count; ++i)
{
ContinuousSolution s = solutions[i];
double[] x = s.Values;
for (int d = 0; d < dimension; ++d)
{
x[d] = x_0[d] + sigma * (x[d] - x_0[d]);
}
s.Values = x;
}
}
public void Contract(List<ContinuousSolution> solutions, ContinuousSolution centroid, double rho, out double[] x_c)
{
int dimension = centroid.Values.Length;
double[] x_centroid = centroid.Values;
int solution_count = solutions.Count - 1;
ContinuousSolution last_solution = solutions[solution_count];
double[] x_last = last_solution.Values;
x_c = new double[dimension];
for (int d = 0; d < dimension; ++d)
{
x_c[d] = x_centroid[d] + rho * (x_centroid[d] - x_last[d]);
}
}
public void Expand(List<ContinuousSolution> solutions, ContinuousSolution centroid, double gamma, out double[] x_e)
{
int dimension = centroid.Values.Length;
double[] x_centroid = centroid.Values;
int solution_count = solutions.Count - 1;
ContinuousSolution last_solution = solutions[solution_count];
double[] x_last = last_solution.Values;
x_e = new double[dimension];
for (int d = 0; d < dimension; ++d)
{
x_e[d] = x_centroid[d] + gamma * (x_centroid[d] - x_last[d]);
}
}
public void Reflect(List<ContinuousSolution> solutions, ContinuousSolution centroid, double alpha, out double[] x_r)
{
int dimension = centroid.Values.Length;
double[] x_centroid = centroid.Values;
int solution_count = solutions.Count - 1;
ContinuousSolution last_solution = solutions[solution_count];
double[] x_last = last_solution.Values;
x_r = new double[dimension];
for (int d = 0; d < dimension; ++d)
{
x_r[d] = x_centroid[d] + alpha * (x_centroid[d] - x_last[d]);
}
}
public void Sort(List<ContinuousSolution> solutions)
{
solutions.Sort((s1, s2) =>
{
return s1.Cost.CompareTo(s2.Cost);
});
//for (int i = 0; i < solutions.Count; ++i)
//{
// Console.WriteLine("Fitness: {0}", solutions[i].Fitness);
//}
}
Project:SquirrelDemo
File:VsSettings.cs
Examples:6
private void OnSolutionOpenedOrClosed(object sender, EventArgs e)
{
_defaultSettings = Settings.LoadDefaultSettings(
GetSolutionSettingsFileSystem(_solutionManager),
configFileName: null,
machineWideSettings: _machineWideSettings);
}
public string GetValue(string section, string key)
{
if (section.Equals(SolutionConfigSection, StringComparison.OrdinalIgnoreCase))
{
return SolutionSettings.GetValue(section, key);
}
return _defaultSettings.GetValue(section, key);
}
public string GetValue(string section, string key, bool isPath)
{
if (section.Equals(SolutionConfigSection, StringComparison.OrdinalIgnoreCase))
{
return SolutionSettings.GetValue(section, key, isPath);
}
return _defaultSettings.GetValue(section, key, isPath);
}
public IList<KeyValuePair<string, string>> GetValues(string section)
{
return GetSettingValues(section, isPath: false)
.Select(v => new KeyValuePair<string, string>(v.Key, v.Value)).ToList();
}
public IList<SettingValue> GetSettingValues(string section, bool isPath)
{
if (section.Equals(SolutionConfigSection, StringComparison.OrdinalIgnoreCase))
{
return SolutionSettings.GetSettingValues(section, isPath);
}
return _defaultSettings.GetSettingValues(section, isPath);
}
public IList<KeyValuePair<string, string>> GetNestedValues(string section, string key)
{
if (section.Equals(SolutionConfigSection, StringComparison.OrdinalIgnoreCase))
{
return SolutionSettings.GetNestedValues(section, key);
}
return _defaultSettings.GetNestedValues(section, key);
}
Project:Morphos
File:VCProjectFileGenerator.cs
Examples:6
/// <summary>
/// </summary>
public override void CleanProjectFiles(DirectoryReference InMasterProjectDirectory, string InMasterProjectName, DirectoryReference InIntermediateProjectFilesDirectory)
{
FileReference MasterProjectFile = FileReference.Combine(InMasterProjectDirectory, InMasterProjectName);
FileReference MasterProjDeleteFilename = MasterProjectFile + ".sln";
if (MasterProjDeleteFilename.Exists())
{
MasterProjDeleteFilename.Delete();
}
MasterProjDeleteFilename = MasterProjectFile + ".sdf";
if (MasterProjDeleteFilename.Exists())
{
MasterProjDeleteFilename.Delete();
}
MasterProjDeleteFilename = MasterProjectFile + ".suo";
if (MasterProjDeleteFilename.Exists())
{
MasterProjDeleteFilename.Delete();
}
MasterProjDeleteFilename = MasterProjectFile + ".v11.suo";
if (MasterProjDeleteFilename.Exists())
{
MasterProjDeleteFilename.Delete();
}
MasterProjDeleteFilename = MasterProjectFile + ".v12.suo";
if (MasterProjDeleteFilename.Exists())
{
MasterProjDeleteFilename.Delete();
}
// Delete the project files folder
if (InIntermediateProjectFilesDirectory.Exists())
{
try
{
Directory.Delete(InIntermediateProjectFilesDirectory.FullName, true);
}
catch (Exception Ex)
{
Log.TraceInformation("Error while trying to clean project files path {0}. Ignored.", InIntermediateProjectFilesDirectory);
Log.TraceInformation("\t" + Ex.Message);
}
}
}
/// <summary>
/// Allocates a generator-specific project file object
/// </summary>
/// <param name="InitFilePath">Path to the project file</param>
/// <returns>The newly allocated project file object</returns>
protected override ProjectFile AllocateProjectFile(FileReference InitFilePath)
{
return new VCProjectFile(InitFilePath, OnlyGameProject, ProjectFileFormat);
}
/// ProjectFileGenerator interface
public override MasterProjectFolder AllocateMasterProjectFolder(ProjectFileGenerator InitOwnerProjectFileGenerator, string InitFolderName)
{
return new VisualStudioSolutionFolder(InitOwnerProjectFileGenerator, InitFolderName);
}
/// "4.0", "12.0", or "14.0", etc...
static public string GetProjectFileToolVersionString(VCProjectFileFormat ProjectFileFormat)
{
switch (ProjectFileFormat)
{
case VCProjectFileFormat.VisualStudio2012:
return "4.0";
case VCProjectFileFormat.VisualStudio2013:
return "12.0";
case VCProjectFileFormat.VisualStudio2015:
return "14.0";
case VCProjectFileFormat.VisualStudio2017:
return "15.0";
}
return string.Empty;
}
/// for instance: <PlatformToolset>v110</PlatformToolset>
static public string GetProjectFilePlatformToolsetVersionString(VCProjectFileFormat ProjectFileFormat)
{
switch (ProjectFileFormat)
{
case VCProjectFileFormat.VisualStudio2012:
return "v110";
case VCProjectFileFormat.VisualStudio2013:
return "v120";
case VCProjectFileFormat.VisualStudio2015:
return "v140";
case VCProjectFileFormat.VisualStudio2017:
return "v141";
}
return string.Empty;
}
/// <summary>
/// Configures project generator based on command-line options
/// </summary>
/// <param name="Arguments">Arguments passed into the program</param>
/// <param name="IncludeAllPlatforms">True if all platforms should be included</param>
protected override void ConfigureProjectFileGeneration(String[] Arguments, ref bool IncludeAllPlatforms)
{
// Call parent implementation first
base.ConfigureProjectFileGeneration(Arguments, ref IncludeAllPlatforms);
}
Project:SquirrelDemo
File:VsSourceControlTrackerTest.cs
Examples:6
[Fact]
public void ConstructorStartTrackingIfSolutionIsOpen()
{
// Arrange
var solutionManager = new Mock<ISolutionManager>();
var fileSystemProvider = new Mock<IFileSystemProvider>();
var projectDocumentsEvents = new Mock<IVsTrackProjectDocuments2>();
solutionManager.Setup(s => s.IsSolutionOpen).Returns(true);
solutionManager.Setup(s => s.SolutionDirectory).Returns("foo:\\bar");
// Act
var scTracker = new VsSourceControlTracker(
solutionManager.Object, fileSystemProvider.Object, projectDocumentsEvents.Object, new Mock<ISettings>().Object);
// Assert
uint cookie;
projectDocumentsEvents.Verify(
p => p.AdviseTrackProjectDocumentsEvents(It.IsAny<IVsTrackProjectDocumentsEvents2>(), out cookie),
Times.Once());
}
[Fact]
public void StartTrackingIfNewSolutionIsOpen()
{
// Arrange
var solutionManager = new Mock<ISolutionManager>();
var fileSystemProvider = new Mock<IFileSystemProvider>();
var projectDocumentsEvents = new Mock<IVsTrackProjectDocuments2>();
solutionManager.Setup(s => s.IsSolutionOpen).Returns(false);
solutionManager.Setup(s => s.SolutionDirectory).Returns("baz:\\foo");
var fileSystem = new Mock<IFileSystem>();
fileSystemProvider.Setup(f => f.GetFileSystem("baz:\\foo\\.nuget", It.IsAny<bool>())).Returns(fileSystem.Object);
// Act
var scTracker = new VsSourceControlTracker(
solutionManager.Object, fileSystemProvider.Object, projectDocumentsEvents.Object, new Mock<ISettings>().Object);
solutionManager.Raise(s => s.SolutionOpened += (o, e) => { }, EventArgs.Empty);
// Assert
uint cookie;
projectDocumentsEvents.Verify(
p => p.AdviseTrackProjectDocumentsEvents(It.IsAny<IVsTrackProjectDocumentsEvents2>(), out cookie),
Times.Once());
}
[Fact]
public void DoNotTrackIfNewSourceControlIntegrationIsDisabled()
{
// Arrange
var solutionManager = new Mock<ISolutionManager>();
var fileSystemProvider = new Mock<IFileSystemProvider>();
var projectDocumentsEvents = new Mock<IVsTrackProjectDocuments2>();
solutionManager.Setup(s => s.IsSolutionOpen).Returns(true);
solutionManager.Setup(s => s.SolutionDirectory).Returns("baz:\\foo");
var settings = new Mock<ISettings>();
settings.Setup(s => s.GetValue("solution", "disableSourceControlIntegration")).Returns("true");
// Act
var scTracker = new VsSourceControlTracker(
solutionManager.Object, fileSystemProvider.Object, projectDocumentsEvents.Object, settings.Object);
// Assert
uint cookie;
projectDocumentsEvents.Verify(
p => p.AdviseTrackProjectDocumentsEvents(It.IsAny<IVsTrackProjectDocumentsEvents2>(), out cookie),
Times.Never());
}
[Fact]
public void DoNotTrackWhenSolutionIsOpenButSourceControlIntegrationIsDisabled()
{
// Arrange
var solutionManager = new Mock<ISolutionManager>();
var fileSystemProvider = new Mock<IFileSystemProvider>();
var projectDocumentsEvents = new Mock<IVsTrackProjectDocuments2>();
solutionManager.Setup(s => s.IsSolutionOpen).Returns(false);
solutionManager.Setup(s => s.SolutionDirectory).Returns("baz:\\foo");
var settings = new Mock<ISettings>();
settings.Setup(s => s.GetValue("solution", "disableSourceControlIntegration")).Returns("true");
var scTracker = new VsSourceControlTracker(
solutionManager.Object, fileSystemProvider.Object, projectDocumentsEvents.Object, settings.Object);
// Act
solutionManager.Raise(s => s.SolutionOpened += (o, e) => { }, EventArgs.Empty);
// Assert
uint cookie;
projectDocumentsEvents.Verify(
p => p.AdviseTrackProjectDocumentsEvents(It.IsAny<IVsTrackProjectDocumentsEvents2>(), out cookie),
Times.Never());
}
[Fact]
public void StopTrackingWhenSolutionIsClosed()
{
// Arrange
var solutionManager = new Mock<ISolutionManager>();
var fileSystemProvider = new Mock<IFileSystemProvider>();
var projectDocumentsEvents = new Mock<IVsTrackProjectDocuments2>();
solutionManager.Setup(s => s.IsSolutionOpen).Returns(true);
solutionManager.Setup(s => s.SolutionDirectory).Returns("baz:\\foo");
var fileSystem = new MockFileSystem();
fileSystemProvider.Setup(f => f.GetFileSystem("baz:\\foo\\.nuget", It.IsAny<bool>())).Returns(fileSystem);
var scTracker = new VsSourceControlTracker(
solutionManager.Object, fileSystemProvider.Object, projectDocumentsEvents.Object, new Mock<ISettings>().Object);
// Act
solutionManager.Raise(s => s.SolutionClosed += (o, e) => { }, EventArgs.Empty);
// Assert
projectDocumentsEvents.Verify(
p => p.UnadviseTrackProjectDocumentsEvents(It.IsAny<uint>()),
Times.Once());
}
[Fact]
public void RaiseEventWhenSourceControlStateChanged()
{
// Arrange
var solutionManager = new Mock<ISolutionManager>();
var fileSystemProvider = new Mock<IFileSystemProvider>();
var projectDocumentsEvents = new MockIVsTrackProjectDocuments();
solutionManager.Setup(s => s.IsSolutionOpen).Returns(true);
solutionManager.Setup(s => s.SolutionDirectory).Returns("baz:\\foo");
var repositorySettings = new Mock<IRepositorySettings>();
repositorySettings.Setup(r => r.RepositoryPath).Returns("x:\non");
var repositorySettingsLazy = new Lazy<IRepositorySettings>(() => repositorySettings.Object);
var scTracker = new VsSourceControlTracker(
solutionManager.Object, fileSystemProvider.Object, projectDocumentsEvents, new Mock<ISettings>().Object)
{
RepositorySettings = repositorySettingsLazy
};
bool eventRaised = false;
scTracker.SolutionBoundToSourceControl += (o, e) => eventRaised = true;
// Act
projectDocumentsEvents.OnAfterSccStatusChanged(new Mock<IVsProject>().Object, 1, new[] {"sol.sln"},
new[] {(uint) 2});
// Assert
Assert.True(eventRaised);
}
Project:SquirrelDemo
File:SolutionManager.cs
Examples:6
/// <summary>
/// Checks whether the current solution is saved to disk, as opposed to be in memory.
/// </summary>
private bool IsSolutionSavedAsRequired()
{
// Check if user is doing File - New File without saving the solution.
object value;
_vsSolution.GetProperty((int)(__VSPROPID.VSPROPID_IsSolutionSaveAsRequired), out value);
if ((bool)value)
{
return true;
}
// Check if user unchecks the "Tools - Options - Project & Soltuions - Save new projects when created" option
_vsSolution.GetProperty((int)(__VSPROPID2.VSPROPID_DeferredSaveSolution), out value);
return (bool)value;
}
private string GetSolutionFilePath()
{
// Use .Properties.Item("Path") instead of .FullName because .FullName might not be
// available if the solution is just being created
string solutionFilePath = null;
Property property = _dte.Solution.Properties.Item("Path");
if (property == null)
{
return null;
}
try
{
// When using a temporary solution, (such as by saying File -> New File), querying this value throws.
// Since we wouldn't be able to do manage any packages at this point, we return null. Consumers of this property typically
// use a String.IsNullOrEmpty check either way, so it's alright.
solutionFilePath = (string)property.Value;
}
catch (COMException)
{
return null;
}
return solutionFilePath;
}
private bool GetIsSourceControlBound()
{
if (!IsSolutionOpen)
{
return false;
}
string solutionFilePath = GetSolutionFilePath();
Debug.Assert(!String.IsNullOrEmpty(solutionFilePath));
SourceControl2 sourceControl = (SourceControl2)_dte.SourceControl;
if (sourceControl != null)
{
try
{
return sourceControl.GetBindings(solutionFilePath) != null;
}
catch (NotImplementedException)
{
}
}
return false;
}
/// <summary>
/// Gets a list of supported projects currently loaded in the solution
/// </summary>
/// <returns></returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage(
"Microsoft.Design",
"CA1024:UsePropertiesWhereAppropriate",
Justification = "This method is potentially expensive if the cache is not constructed yet.")]
public IEnumerable<Project> GetProjects()
{
if (IsSolutionOpen)
{
EnsureProjectCache();
return _projectCache.GetProjects();
}
else
{
return Enumerable.Empty<Project>();
}
}
public string GetProjectSafeName(Project project)
{
if (project == null)
{
throw new ArgumentNullException("project");
}
// Try searching for simple names first
string name = project.GetName();
if (GetProject(name) == project)
{
return name;
}
return project.GetCustomUniqueName();
}
public Project GetProject(string projectSafeName)
{
if (IsSolutionOpen)
{
EnsureProjectCache();
Project project;
if (_projectCache.TryGetProject(projectSafeName, out project))
{
return project;
}
}
return null;
}
Project:Sharp-Architecture
File:WizardImplementation.cs
Examples:6
// RunStarted() method gets called before the template wizard creates the project.
void IWizard.RunStarted(object application, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) {
this.dte = application as EnvDTE._DTE;
this.runKind = runKind;
this.replacementsDictionary = replacementsDictionary;
// Store the solution name locally while processing the solution template
if (runKind == WizardRunKind.AsMultiProject) {
solutionName = replacementsDictionary["$safeprojectname$"];
}
replacementsDictionary.Add("$solutionname$", solutionName);
if (runKind == WizardRunKind.AsNewProject) {
// Make the solution root path available for all the projects
replacementsDictionary.Add("$solutionrootpath$", GetSolutionRootPath() + solutionName + "\\");
AddProjectGuidsTo(replacementsDictionary);
}
}
/// <summary>
/// Makes the project GUIDs, which are collected during the project creation process,
/// available to subsequent projects
/// </summary>
private static void AddProjectGuidsTo(Dictionary<string, string> replacementsDictionary) {
replacementsDictionary.Add("$guidAssignedToCore$", guidAssignedToCore);
replacementsDictionary.Add("$guidAssignedToData$", guidAssignedToData);
replacementsDictionary.Add("$guidAssignedToApplicationServices$", guidAssignedToApplicationServices);
replacementsDictionary.Add("$guidAssignedToControllers$", guidAssignedToControllers);
}
/// <summary>
/// Runs custom wizard logic when a project has finished generating
/// </summary>
void IWizard.ProjectFinishedGenerating(EnvDTE.Project project) {
if (project != null) {
if (project.Name == "SolutionItemsContainer") {
PerformSolutionInitialization(project);
MoveSolutionItemsToLib(project);
}
else if (project.Name == "ToolsSolutionItemsContainer") {
MoveSolutionItemsToToolsLib(project);
}
else if (project.Name == "CrudScaffolding") {
Project movedProject = MoveProjectTo("\\tools\\", project, "Code Generation");
ExcludeProjectFromBuildProcess(movedProject);
}
else if (project.Name == GetSolutionName() + ".Tests") {
MoveProjectTo("\\tests\\", project);
}
else if (project.Name == GetSolutionName() + ".Web.Controllers" ||
project.Name == GetSolutionName() + ".ApplicationServices" ||
project.Name == GetSolutionName() + ".Core" ||
project.Name == GetSolutionName() + ".Data" ||
project.Name == GetSolutionName() + ".Web") {
Project movedProject = MoveProjectTo("\\app\\", project);
// Give the solution time to release the lock on the project file
System.Threading.Thread.Sleep(MIN_TIME_FOR_PROJECT_TO_RELEASE_FILE_LOCK);
CaptureProjectGuidOf(movedProject);
}
}
}
private void CaptureProjectGuidOf(Project project) {
if (IsProjectReferredByOtherProjects(project)) {
string projectPath = GetSolutionRootPath() + GetSolutionName() + "\\app\\" + project.Name + "\\" + project.Name + ".csproj";
Log("CaptureProjectGuidOf: Does " + projectPath + " exist? " + File.Exists(projectPath).ToString());
Log("CaptureProjectGuidOf: About to open " + projectPath);
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(projectPath);
XmlNodeList projectGuidNodes = xmlDocument.GetElementsByTagName("ProjectGuid");
if (projectGuidNodes == null || projectGuidNodes.Count == 0)
throw new ApplicationException("Couldn't find a matching node in the project file for ProjectGuid");
StoreCapturedGuidForLaterUse(project, projectGuidNodes);
Log("CaptureProjectGuidOf: Captured the GUID " + projectGuidNodes[0].InnerText + " for " + project.Name);
}
}
private void StoreCapturedGuidForLaterUse(Project project, XmlNodeList projectGuidNodes) {
if (project.Name == GetSolutionName() + ".ApplicationServices") {
guidAssignedToApplicationServices = projectGuidNodes[0].InnerText;
}
else if (project.Name == GetSolutionName() + ".Core") {
guidAssignedToCore = projectGuidNodes[0].InnerText;
}
else if (project.Name == GetSolutionName() + ".Web.Controllers") {
guidAssignedToControllers = projectGuidNodes[0].InnerText;
}
else if (project.Name == GetSolutionName() + ".Data") {
guidAssignedToData = projectGuidNodes[0].InnerText;
}
}
private bool IsProjectReferredByOtherProjects(Project project) {
return project.Name == GetSolutionName() + ".ApplicationServices" ||
project.Name == GetSolutionName() + ".Core" ||
project.Name == GetSolutionName() + ".Web.Controllers" ||
project.Name == GetSolutionName() + ".Data";
}
Project:cs-optimization-continuous-solutions
File:ScatterSearch.cs
Examples:6
protected ContinuousSolution DoLocalSearch(double[] x, CostEvaluationMethod evaluate, GradientEvaluationMethod calc_gradient, object constraints)
{
if (mLocalSearch != null)
{
return mLocalSearch.Minimize(x, evaluate, calc_gradient, mLocalSearchTerminationCondition, constraints);
}
double fx = evaluate(x, mLowerBounds, mUpperBounds, constraints);
return new ContinuousSolution(x, fx);
}
protected double[] CreateRandomSolution(CostEvaluationMethod evaluate, double[] lower_bounds, double[] upper_bounds, object constraints)
{
return mSolutionGenerator(evaluate, lower_bounds, upper_bounds, constraints);
}
protected ContinuousSolution[] Diversify(List<ContinuousSolution> diverse_set)
{
ContinuousSolution[] ref_set = new ContinuousSolution[mReferenceSetSize];
for (int i = 0; i < mNumElite; ++i)
{
ref_set[i] = diverse_set[i];
}
int remainder_set_size = mDiverseSetSize - mNumElite;
ContinuousSolution[] remainder_set = new ContinuousSolution[remainder_set_size];
for (int i = mNumElite; i < mDiverseSetSize; ++i)
{
remainder_set[i - mNumElite] = diverse_set[i];
}
Dictionary<ContinuousSolution, double> remainder_distance_set = new Dictionary<ContinuousSolution, double>();
for (int i = 0; i < remainder_set_size; ++i)
{
double distance = 0;
for (int j = 0; j < mNumElite; ++j)
{
distance += remainder_set[i].GetDistance2(ref_set[j]);
}
remainder_distance_set[remainder_set[i]] = distance;
}
remainder_set = remainder_set.OrderBy(s => remainder_distance_set[s]).ToArray();
for (int i = mNumElite; i < mReferenceSetSize; ++i)
{
ref_set[i] = remainder_set[i - mNumElite];
}
return ref_set;
}
protected List<ContinuousSolution> ConstructDiverseSet(CostEvaluationMethod evaluate, GradientEvaluationMethod calc_grad, object constraints)
{
double[] x = null;
ContinuousSolution best_solution = new ContinuousSolution();
double? improvement2 = null;
List<ContinuousSolution> diverse_set = new List<ContinuousSolution>();
while (diverse_set.Count < mReferenceSetSize)
{
x = CreateRandomSolution(evaluate, mLowerBounds, mUpperBounds, constraints);
ContinuousSolution xs = DoLocalSearch(x, evaluate, calc_grad, constraints);
double minDistanceSq = double.MaxValue;
double distanceSq = 0;
bool contains_item = false;
foreach (ContinuousSolution s in diverse_set)
{
distanceSq = s.GetDistanceSq2(xs);
if (distanceSq.Equals(minDistanceSq))
{
contains_item = true;
break;
}
}
if (!contains_item)
{
diverse_set.Add(xs);
}
best_solution.TryUpdateSolution(xs.Values, xs.Cost, out improvement2);
}
return diverse_set;
}
protected List<ContinuousSolution[]> SelectSubsets(ContinuousSolution[] ref_set)
{
List<ContinuousSolution> additions = new List<ContinuousSolution>();
List<ContinuousSolution> remainders = new List<ContinuousSolution>();
for (int i = 0; i < mReferenceSetSize; ++i)
{
if (ref_set[i].IsNew())
{
additions.Add(ref_set[i]);
}
else
{
remainders.Add(ref_set[i]);
}
}
if (remainders.Count == 0)
{
foreach (ContinuousSolution s in additions)
{
remainders.Add(s);
}
}
List<ContinuousSolution[]> subsets = new List<ContinuousSolution[]>();
for (int i = 0; i < additions.Count; ++i)
{
ContinuousSolution addition = additions[i];
for (int j = 0; j < remainders.Count; ++j)
{
ContinuousSolution remainder = remainders[j];
if (addition != remainder)
{
subsets.Add(new ContinuousSolution[] { remainder, addition });
}
}
}
return subsets;
}
public ContinuousSolution[] Recombine(ContinuousSolution[] subset, object constraints)
{
ContinuousSolution a = subset[0];
ContinuousSolution b = subset[1];
ContinuousSolution d = (a - b) / 2;
double[] lower_bounds = null;
double[] upper_bounds = null;
if (mLowerBounds == null || mUpperBounds == null)
{
if (constraints != null && constraints is Tuple<double[], double[]>)
{
Tuple<double[], double[]> bounds = constraints as Tuple<double[], double[]>;
lower_bounds = bounds.Item1;
upper_bounds = bounds.Item2;
}
else
{
throw new InvalidCastException();
}
}
else
{
lower_bounds = mLowerBounds;
upper_bounds = mUpperBounds;
}
if (lower_bounds.Length < d.Length)
{
throw new IndexOutOfRangeException();
}
if (upper_bounds.Length < d.Length)
{
throw new IndexOutOfRangeException();
}
ContinuousSolution[] children = new ContinuousSolution[subset.Length];
for (int i = 0; i < subset.Length; ++i)
{
double[] x = new double[d.Length];
for (int j = 0; j < d.Length; ++j)
{
int direction = RandomEngine.NextDouble() < 0.5 ? 1 : -1;
double r = RandomEngine.NextDouble();
x[j] = subset[i][j] + d[j] * direction * r;
x[j] = System.Math.Max(lower_bounds[j], x[j]);
x[j] = System.Math.Min(upper_bounds[j], x[j]);
}
children[i] = new ContinuousSolution(x, double.MaxValue);
}
return children;
}
Project:SquirrelDemo
File:SolutionFolderFileSystem.cs
Examples:6
public override void AddFile(string path, Stream stream)
{
AddFileCore(path, () => base.AddFile(path, stream));
}
public override void AddFile(string path, Action<Stream> writeToStream)
{
AddFileCore(path, () => base.AddFile(path, writeToStream));
}
private void AddFileCore(string path, Action action)
{
EnsureSolutionFolder();
if (_solutionFolder != null)
{
bool fileExistsInProject = FileExistsInProject(path);
if (fileExistsInProject)
{
// If the file already exists, check it out.
_solutionFolder.EnsureCheckedOutIfExists(this, path);
}
action();
if (!fileExistsInProject)
{
// Add the file to the solution directory if it does not already exist.
var fullPath = GetFullPath(path);
_solutionFolder.ProjectItems.AddFromFile(fullPath);
}
}
}
public override void DeleteFile(string path)
{
EnsureSolutionFolder();
if (_solutionFolder != null && FileExistsInProject(path))
{
_solutionFolder.DeleteProjectItem(path);
}
base.DeleteFile(path);
}
private void EnsureSolutionFolder()
{
if (!_ensureProjectCalled)
{
_ensureProjectCalled = true;
_solutionFolder = _solution.GetSolutionFolder(_solutionFolderPath);
}
}
private bool FileExistsInProject(string path)
{
return _solutionFolder.GetProjectItem(path) != null;
}
Project:Morphos
File:UnrealVSPackage.cs
Examples:6
/// <summary>
/// Initializes the package right after it's been "sited" into the fully-initialized Visual Studio IDE.
/// </summary>
protected override void Initialize()
{
Logging.WriteLine("Initializing UnrealVS extension...");
// Grab the MenuCommandService
MenuCommandService = GetService( typeof( IMenuCommandService ) ) as OleMenuCommandService;
// Get access to Visual Studio's DTE object. This object has various hooks into the Visual Studio
// shell that are useful for writing extensions.
DTE = (DTE)GetGlobalService( typeof( DTE ) );
Logging.WriteLine("DTE version " + DTE.Version);
// Get selection manager and register to receive events
SelectionManager =
ServiceProvider.GlobalProvider.GetService(typeof (SVsShellMonitorSelection)) as IVsMonitorSelection;
SelectionManager.AdviseSelectionEvents( this, out SelectionEventsHandle );
// Get solution and register to receive events
SolutionManager = ServiceProvider.GlobalProvider.GetService( typeof( SVsSolution ) ) as IVsSolution2;
UpdateUnrealLoadedStatus();
SolutionManager.AdviseSolutionEvents( this, out SolutionEventsHandle );
// Grab the solution build manager. We need this in order to change certain things about the Visual
// Studio environment, like what the active startup project is
// Get solution build manager
SolutionBuildManager =
ServiceProvider.GlobalProvider.GetService(typeof (SVsSolutionBuildManager)) as IVsSolutionBuildManager2;
SolutionBuildManager.AdviseUpdateSolutionEvents(this, out UpdateSolutionEventsHandle);
// Create our command-line editor
CommandLineEditor = new CommandLineEditor();
// Create our startup project selector
StartupProjectSelector = new StartupProjectSelector();
// Create 'BuildStartupProject' instance
BuildStartupProject = new BuildStartupProject();
// Create 'CompileSingleFile' instance
CompileSingleFile = new CompileSingleFile();
// Create 'GenerateProjectFiles' tools
GenerateProjectFiles = new GenerateProjectFiles();
// Create Batch Builder tools
BatchBuilder = new BatchBuilder();
// Create the project menu quick builder
QuickBuilder = new QuickBuild();
// Call parent implementation
base.Initialize();
if (DTE.Solution.IsOpen)
{
StartTicker();
}
}
private void StartTicker()
{
// Create a "ticker" on a background thread that ticks the package on the UI thread
Interlocked.Exchange(ref bCancelTicker, 0);
Ticker = new Thread(TickAsyncMain);
Ticker.Priority = ThreadPriority.Lowest;
Ticker.Start();
}
private void StopTicker()
{
if (bCancelTicker == 0)
{
Interlocked.Exchange(ref bCancelTicker, 1);
}
}
/// <summary>
/// Tick loop on worker thread
/// </summary>
private void TickAsyncMain()
{
try
{
while (true)
{
if (bCancelTicker != 0) return;
ThreadHelper.Generic.BeginInvoke(Tick);
if (bCancelTicker != 0) return;
Thread.Sleep(TickPeriod);
}
}
catch (ThreadAbortException)
{
}
}
/// <summary>
/// Tick function on main UI thread
/// </summary>
private void Tick()
{
BatchBuilder.Tick();
}
/// <summary>
/// Implementation from IDisposable
/// </summary>
public void Dispose()
{
Dispose(true);
}
Project:HarmonyCore
File:CodegenCommand.cs
Examples:4
private void LazyLoadLookups()
{
if (_structureLookup == null)
_structureLookup = _solutionInfo.CodeGenSolution.RPS.Structures.ToDictionary(strc => strc.Name, StringComparer.OrdinalIgnoreCase);
if (_extendedStructureLookup == null)
_extendedStructureLookup = _solutionInfo.CodeGenSolution.ExtendedStructures.ToDictionary(strc => strc.Name, StringComparer.OrdinalIgnoreCase);
if (_interfaceLookup == null)
_interfaceLookup = _solutionInfo.CodeGenSolution.TraditionalBridge.Smc.Interfaces.ToDictionary(iface => iface.Name, StringComparer.OrdinalIgnoreCase);
if (_extendedInterfaceLookup == null)
_extendedInterfaceLookup = _solutionInfo.CodeGenSolution.ExtendedInterfaces.ToDictionary(iface => iface.Name, StringComparer.OrdinalIgnoreCase);
}
public int Add(CodegenAddOptions opts)
{
LazyLoadLookups();
if (opts.Interface)
{
foreach (var interfaceName in opts.Items)
{
if (!_interfaceLookup.TryGetValue(interfaceName, out var rpsIFace))
{
Console.WriteLine("failed to find interface {0} in smc", interfaceName);
return -1;
}
if (!_extendedInterfaceLookup.TryGetValue(interfaceName, out var interfaceEx))
{
interfaceEx = new HarmonyCoreGenerator.Model.InterfaceEx { Name = interfaceName };
_extendedInterfaceLookup.Add(interfaceName, interfaceEx);
_solutionInfo.CodeGenSolution.ExtendedInterfaces.Add(interfaceEx);
}
interfaceEx.GenerateWebAPIController = opts.TBWebApi;
interfaceEx.GenerateSignalRHub = opts.TBSignalR;
interfaceEx.GenerateInterface = true;
}
}
else if (opts.Structure)
{
foreach (var structureName in opts.Items)
{
string alias = null;
string name = null;
//if we have an alias spec split it
if (structureName.Contains(":"))
{
var aliasSplit = structureName.Split(':');
name = aliasSplit[0];
alias = aliasSplit[1];
}
else
{
name = structureName;
}
if (!_structureLookup.TryGetValue(name, out var rpsStruct))
{
Console.WriteLine("failed to find structure {0} in repository", name);
return -1;
}
if (!_extendedStructureLookup.TryGetValue(name, out var structEx))
{
structEx = new HarmonyCoreGenerator.Model.StructureEx { Name = name, Aliases = new List<string> { alias } };
_extendedStructureLookup.Add(name, structEx);
_solutionInfo.CodeGenSolution.ExtendedStructures.Add(structEx);
}
else
{
structEx.Aliases.Add(alias);
}
if (structEx.EnabledGenerators == null)
structEx.EnabledGenerators = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
if (opts.OData)
{
if (!structEx.EnabledGenerators.Contains(nameof(ODataGenerator)))
structEx.EnabledGenerators.Add(nameof(ODataGenerator));
if (!structEx.EnabledGenerators.Contains(nameof(EFCoreGenerator)))
structEx.EnabledGenerators.Add(nameof(EFCoreGenerator));
if (!structEx.EnabledGenerators.Contains(nameof(ModelGenerator)))
structEx.EnabledGenerators.Add(nameof(ModelGenerator));
}
if (opts.Custom)
{
if (!structEx.EnabledGenerators.Contains(nameof(ModelGenerator)))
structEx.EnabledGenerators.Add(nameof(ODataGenerator));
}
if (opts.Ef)
{
if (!structEx.EnabledGenerators.Contains(nameof(ModelGenerator)))
structEx.EnabledGenerators.Add(nameof(ModelGenerator));
if (!structEx.EnabledGenerators.Contains(nameof(EFCoreGenerator)))
structEx.EnabledGenerators.Add(nameof(EFCoreGenerator));
}
}
}
else
{
Console.WriteLine("invalid arguments");
return -1;
}
_solutionInfo.SaveSolution();
return 0;
}
public int Remove(CodegenRemoveOptions opts)
{
LazyLoadLookups();
if (opts.Interface)
{
foreach (var interfaceName in opts.Items)
{
if (!_interfaceLookup.TryGetValue(interfaceName, out var rpsInterface))
{
Console.WriteLine("failed to find interface {0} in smc", interfaceName);
return -1;
}
if (_extendedInterfaceLookup.TryGetValue(interfaceName, out var interfaceEx))
{
_solutionInfo.CodeGenSolution.ExtendedInterfaces.Remove(interfaceEx);
_extendedInterfaceLookup.Remove(interfaceName);
}
}
}
else if (opts.Structure)
{
foreach (var structureName in opts.Items)
{
if (!_structureLookup.TryGetValue(structureName, out var rpsStructure))
{
Console.WriteLine("failed to find structure {0} in repository", structureName);
return -1;
}
if (_extendedStructureLookup.TryGetValue(structureName, out var structEx))
{
_solutionInfo.CodeGenSolution.ExtendedStructures.Remove(structEx);
_extendedStructureLookup.Remove(structureName);
}
}
}
_solutionInfo.SaveSolution();
return 0;
}
public int List(CodegenListOptions opts)
{
foreach (var structure in _solutionInfo.CodeGenSolution.ExtendedStructures)
{
if ((structure.Aliases?.Count ?? 0) > 0)
{
Console.WriteLine("{0} -> {1} : {2}", structure.Name, string.Join("|", structure.Aliases), string.Join("|", structure.EnabledGenerators));
}
else
Console.WriteLine("{0} : {1}", structure.Name, string.Join("|", structure.EnabledGenerators));
}
return 0;
}
Microsoft.Azure.Management.AppService.Fluent.Models.Solution : Object
Constructors :
public Solution()public Solution(Nullable<Double> id = null, String displayName = null, Nullable<Double> order = null, String description = null, Nullable<SolutionType> type = null, IList<IList<NameValuePair>> data = null, IList<IList<NameValuePair>> metadata = null)
Methods :
public Nullable<Double> get_Id()public Void set_Id(Nullable<Double> value = )
public String get_DisplayName()
public Void set_DisplayName(String value = )
public Nullable<Double> get_Order()
public Void set_Order(Nullable<Double> value = )
public String get_Description()
public Void set_Description(String value = )
public Nullable<SolutionType> get_Type()
public Void set_Type(Nullable<SolutionType> value = )
public IList<IList<NameValuePair>> get_Data()
public Void set_Data(IList<IList<NameValuePair>> value = )
public IList<IList<NameValuePair>> get_Metadata()
public Void set_Metadata(IList<IList<NameValuePair>> value = )
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()