protected override void DrawCore(IEnumerable<Feature> features, GeoCanvas canvas, Collection<SimpleCandidate> labelsInThisLayer, Collection<SimpleCandidate> labelsInAllLayers) { var startPointShapes = new Collection<BaseShape>(); var endPointShapes = new Collection<BaseShape>(); var lineShapes = new Collection<BaseShape>(); //Loops thru the features to display the first and end point of each LineShape of the MultilineShape. foreach (var feature in features) { var shape = feature.GetShape(); lineShapes.Add(shape); if (shape is MultilineShape) { var multilineShape = (MultilineShape)shape; for (var i = 0; i <= multilineShape.Lines.Count - 1; i++) { var lineShape = multilineShape.Lines[i]; startPointShapes.Add(new PointShape(lineShape.Vertices[0])); endPointShapes.Add(new PointShape(lineShape.Vertices[lineShape.Vertices.Count - 1])); } } else if (shape is LineShape) { var lineShape = (LineShape) shape; startPointShapes.Add(new PointShape(lineShape.Vertices[0])); endPointShapes.Add(new PointShape(lineShape.Vertices[lineShape.Vertices.Count - 1])); } } _lineStyle.Draw(lineShapes, canvas, labelsInThisLayer, labelsInAllLayers); _startPointStyle.Draw(startPointShapes, canvas, labelsInThisLayer, labelsInAllLayers); _endPointStyle.Draw(endPointShapes, canvas, labelsInThisLayer, labelsInAllLayers); }
public string[] ToArray(bool obfuscate = false) { var parameters = new Collection<string> { Cli, "--key", obfuscate ? string.Format("********-****-****-****-********{0}", Key.Substring(Key.Length - 4)) : Key, "--file", File, "--plugin", Plugin }; if (IsWrite) parameters.Add("--write"); // ReSharper disable once InvertIf if (!string.IsNullOrEmpty(Project)) { parameters.Add("--project"); parameters.Add(Project); } return parameters.ToArray(); }
public virtual IList GetSaleHistoriesOrderByProductCategory(IList searchCriteria) { var criterionList = new Collection<ICriterion>(); if (searchCriteria != null) { foreach (string strCriteria in searchCriteria) { var delimiterIndex = strCriteria.IndexOf("|"); if (delimiterIndex >= 0) criterionList.Add( Expression.Eq( StringHelper.Left(strCriteria, delimiterIndex), StringHelper.Right(strCriteria, strCriteria.Length - delimiterIndex - 1))); else criterionList.Add(Expression.Sql(strCriteria)); } } var orderList = new Collection<Order> { Order.Asc(SaleOrderReport.ConstSaleOrderProductCategory) }; return SelectObjects(typeof(SaleOrderReport), criterionList, orderList).List(); }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { var s = value as string; if (s != null) { var c = new Collection<HorizontalAlignment>(); foreach (var item in s.Split(SplitterChars)) { if (!String.IsNullOrEmpty(item)) { var itemL = item.ToLower(); if (itemL.StartsWith("l")) { c.Add(HorizontalAlignment.Left); continue; } if (itemL.StartsWith("r")) { c.Add(HorizontalAlignment.Right); continue; } if (itemL.StartsWith("s")) { c.Add(HorizontalAlignment.Stretch); continue; } } c.Add(HorizontalAlignment.Center); } return c; } return base.ConvertFrom(context, culture, value); }
public CompressionHandler() { Compressors = new Collection<ICompressor>(); Compressors.Add(new GZipCompressor()); Compressors.Add(new DeflateCompressor()); }
public static JwtSecurityToken CreateToken(IEnumerable<Claim> claims, string secretKey, string audience, string issuer, TimeSpan? lifetime) { if (claims == null) { throw new ArgumentNullException("claims"); } if (lifetime != null && lifetime < TimeSpan.Zero) { string msg = CommonResources.ArgMustBeGreaterThanOrEqualTo.FormatForUser(TimeSpan.Zero); throw new ArgumentOutOfRangeException("lifetime", lifetime, msg); } if (string.IsNullOrEmpty(secretKey)) { throw new ArgumentNullException("secretKey"); } if (claims.SingleOrDefault(c => c.Type == JwtRegisteredClaimNames.Sub) == null) { throw new ArgumentOutOfRangeException("claims", LoginResources.CreateToken_SubjectRequired); } // add the claims passed in Collection<Claim> finalClaims = new Collection<Claim>(); foreach (Claim claim in claims) { finalClaims.Add(claim); } // add our standard claims finalClaims.Add(new Claim("ver", "3")); return CreateTokenFromClaims(finalClaims, secretKey, audience, issuer, lifetime); }
/// <summary> /// Tests a Digital Signature from a package /// </summary> /// <returns>Digital signatures list</returns> public static Collection<string> GetList(OpenXmlPowerToolsDocument doc) { using (OpenXmlMemoryStreamDocument streamDoc = new OpenXmlMemoryStreamDocument(doc)) { // Creates the PackageDigitalSignatureManager PackageDigitalSignatureManager digitalSignatureManager = new PackageDigitalSignatureManager(streamDoc.GetPackage()); // Verifies the collection of certificates in the package Collection<string> digitalSignatureDescriptions = new Collection<string>(); ReadOnlyCollection<PackageDigitalSignature> digitalSignatures = digitalSignatureManager.Signatures; if (digitalSignatures.Count > 0) { foreach (PackageDigitalSignature signature in digitalSignatures) { if (PackageDigitalSignatureManager.VerifyCertificate(signature.Signer) != X509ChainStatusFlags.NoError) { digitalSignatureDescriptions.Add(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Signature: {0} ({1})", signature.Signer.Subject, PackageDigitalSignatureManager.VerifyCertificate(signature.Signer))); } else digitalSignatureDescriptions.Add("Signature: " + signature.Signer.Subject); } } else { digitalSignatureDescriptions.Add("No digital signatures found"); } return digitalSignatureDescriptions; } }
public void ComparisonTest(Action test1, Action test2, TestSettings settings = null) { settings = settings ?? new TestSettings(); Console.WriteLine("Running tests"); var consoleCursorTop = Console.CursorTop; var test1Results = new Collection<TestResult>(); var test2Results = new Collection<TestResult>(); foreach (var iteration in Enumerable.Range(1, settings.Iterations)) { Console.SetCursorPosition(0, consoleCursorTop); Console.WriteLine("Running iteration {0}", iteration); var swapOrder = RandomHelper.TrueOrFalse(); if (swapOrder) { test2Results.Add(RunTest(test2)); test1Results.Add(RunTest(test1)); } else { test1Results.Add(RunTest(test1)); test2Results.Add(RunTest(test2)); } } Console.SetCursorPosition(0, consoleCursorTop); Console.WriteLine("".PadRight(Console.BufferWidth - 1)); var averageTest1 = test1Results.Average(r => r.Elapsed.TotalSeconds); var averageTest2 = test2Results.Average(r => r.Elapsed.TotalSeconds); Console.WriteLine("Test 1 average: {0}", averageTest1); Console.WriteLine("Test 2 average: {0}", averageTest2); }
public byte[] Encode() { Collection<byte> collection1 = new Collection<byte>(); collection1.Add(100); ArrayList list1 = new ArrayList(); foreach (string text1 in dict.Keys) { list1.Add(text1); } foreach (string text2 in list1) { ValueString text3 = new ValueString(text2); foreach (byte num1 in text3.Encode()) { collection1.Add(num1); } foreach (byte num2 in dict[text2].Encode()) { collection1.Add(num2); } } collection1.Add(0x65); byte[] buffer1 = new byte[collection1.Count]; collection1.CopyTo(buffer1, 0); return buffer1; }
private void SetUpData() { Domain.Dependencies.Register(); //Repository registration DIContainer.Instance.RegisterType<IRepository, OnlineRepository>(OnlineRepository.InstanceName); DIContainer.Instance.RegisterType<ReferenceDataRepository>(new ContainerControlledLifetimeManager()); DIContainer.Instance.RegisterType<IComponentSettingsClient, ComponentSettingsClientTest>(); var workStation = DIContainer.Instance.Resolve<Workstation>(); workStation.ConfigurationServiceBaseAddress = "http://Localhost/"; workStation.Ship = new Ship { ShipId = "1", BrandId = "3", Code = "3" }; workStation.ConnectionMode = ConnectionMode.Online; var intCollection = new Collection<int>(); intCollection.Add(1); intCollection.Add(2); intCollection.Add(3); var brand = new Brand { BrandId = "3", Name = "Carnival Breeze", MediaItemAddress = "http://172.26.248.122/ImagingMediaService/MediaItems/23" }; brand.AssignPortIds(intCollection); workStation.Brand = brand; workStation.Voyage = new Voyage { IsActive = true, VoyageId = "31", Number = "dd0", ShipId = "1" }; var voyages = new List<Voyage>(); voyages.Add(new Voyage { IsActive = true, VoyageId = "31", Number = "dd0", ShipId = "1" }); workStation.AssignVoyageList(voyages); this.targetRepository = new ConfigurationServiceRepository(); }
public string[] ToArray(bool obfuscate = false) { var key = WakaTimeConfigFile.ApiKey; var parameters = new Collection<string> { WakaTimeCli.GetCliPath(), "--key", obfuscate ? string.Format("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX{0}", key.Substring(key.Length - 4)) : key, "--file", File, "--plugin", Plugin }; if (IsWrite) parameters.Add("--write"); // ReSharper disable once InvertIf if (!string.IsNullOrEmpty(Project)) { parameters.Add("--project"); parameters.Add(Project); } return parameters.ToArray(); }
public virtual IList GetAppParameters(IList searchCriteria) { var criterionList = new Collection<ICriterion>(); if (searchCriteria != null) { foreach (string strCriteria in searchCriteria) { var delimiterIndex = strCriteria.IndexOf("|"); if (delimiterIndex >= 0) criterionList.Add(Expression.Eq( StringHelper.Left(strCriteria, delimiterIndex), StringHelper.Right(strCriteria, strCriteria.Length - delimiterIndex - 1))); else criterionList.Add(Expression.Sql(strCriteria)); } } criterionList.Add( Expression.Sql("ParameterTypeId IN (SELECT ParameterTypeId FROM TAppParameterTypes WHERE IsActive = 1)")); var orderList = new Collection<Order> {Order.Asc("ParameterTypeId"), Order.Asc("ParameterLabel")}; return SelectObjects(typeof (AppParameter), criterionList, orderList).List(); }
private IEnumerable<Property> BuildResponseProperties(ClientGeneratorMethod method) { var properties = new Collection<Property>(); if (method.ReturnType != "string" && method.ReturnType != "HttpContent") { properties.Add(new Property { Name = "Content", Description = "Typed Response content", Type = method.ReturnType }); } if (method.ResponseHeaders != null && method.ResponseHeaders.Any()) { properties.Add(new Property { Name = "Headers", Description = "Typed Response headers (defined in RAML)", Type = method.ResponseHeaderType }); } return properties; }
public ResentDateModel () { Items = new Collection<ResentDateItemModel>(); Items.Add(new ResentDateItemModel () ); Items.Add(new ResentDateItemModel()); Items.Add(new ResentDateItemModel()); }
public override Collection<PSAdaptedProperty> GetProperties(object baseObject) { CimInstance cimInstance = baseObject as CimInstance; if (cimInstance == null) { throw new PSInvalidOperationException(string.Format(CultureInfo.InvariantCulture, CimInstanceTypeAdapterResources.BaseObjectNotCimInstance, new object[] { "baseObject", typeof(CimInstance).ToString() })); } Collection<PSAdaptedProperty> collection = new Collection<PSAdaptedProperty>(); if (cimInstance.CimInstanceProperties != null) { foreach (CimProperty property in cimInstance.CimInstanceProperties) { PSAdaptedProperty cimPropertyAdapter = GetCimPropertyAdapter(property, baseObject); if (cimPropertyAdapter != null) { collection.Add(cimPropertyAdapter); } } } PSAdaptedProperty pSComputerNameAdapter = GetPSComputerNameAdapter(cimInstance); if (pSComputerNameAdapter != null) { collection.Add(pSComputerNameAdapter); } return collection; }
public SolutionProjectsPage(WizardParams Params) : base(Params) { InitializeComponent(); if (PK.Wrapper.GetProjectTemplates().Count == 0) { PK.Wrapper.LoadTemplateProjects(); } _treeView.NodeControls.Clear(); NodeCheckBox checkBox = _treeView.AddCheckBoxControl("Checked"); checkBox.IsVisibleValueNeeded += new EventHandler<NodeControlValueEventArgs>(checkBox_IsVisibleValueNeeded); checkBox.IsEditEnabledValueNeeded += new EventHandler<NodeControlValueEventArgs>(checkBox_IsVisibleValueNeeded); _treeView.AddIconControl("Icon"); _treeView.AddTextBoxControl("Name"); List<ComponentWrapper> nativeProjects = new List<ComponentWrapper>(); List<ComponentWrapper> clrProjects = new List<ComponentWrapper>(); foreach (ProjectWrapper project in PK.Wrapper.GetProjectTemplates()) { ComponentWrapper component = ComponentWrapper.GetComponentWrapper(project); if (project.IsClrProject) clrProjects.Add(component); else nativeProjects.Add(component); } Collection<RootNode> roots = new Collection<RootNode>(); roots.Add(new RootNode(null, "Native Projects", nativeProjects.ToArray())); roots.Add(new RootNode(null, "CLR Projects", clrProjects.ToArray())); _treeView.SetModel(InventoryBrowserModel.GetModel(roots), true); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); // Check if our robot connection is setup if (!App.setupComplete) { var action = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, new Windows.UI.Core.DispatchedHandler(() => { this.Frame.Navigate(typeof(ArduinoConnectionPage)); } )); } else { // Create robot control interface App.control = new RomeoControl(); } Collection<String> controllers = new Collection<string>(); controllers.Add("Dpad Controller"); controllers.Add("Tank Controller"); // Add new controllers here listBox.ItemsSource = controllers; }
private static void Main() { ICollection<string> myCole = new Collection<string>(); //Initializing a collection of strings myCole.Add("Takane"); //Adding elements on a collection myCole.Add("Sena"); myCole.Add("Masuzu"); myCole.Add("Yusa Emi"); foreach(string b in myCole){ Console.WriteLine("myCole contains " + b); } myCole.Remove("Yusa Emi"); //removing an element on a collection Console.WriteLine("Deleted an element"); bool a = myCole.Contains("Takane"); //tells whether the collection contains a certain element //enumerate the elements foreach(string b in myCole){ Console.WriteLine("myCole contains " + b); } //copying the content of a collection to an array string[] c = new string[myCole.Count]; // initializes the array with the size equal to myCole myCole.CopyTo(c, 0); //Copy to string array c from element 0 foreach(string d in c){ Console.WriteLine("String Copy in c: {0}", d); } }
public override void OnControlLoad(object sender, EventArgs e) { string accountNumber = this.Page.Request["AccountNumber"]; DateTime from = Conversion.TryCastDate(this.Page.Request["From"]); DateTime to = Conversion.TryCastDate(this.Page.Request["To"]); int userId = AppUsers.GetCurrent().View.UserId.ToInt(); int officeId = AppUsers.GetCurrent().View.OfficeId.ToInt(); Collection<KeyValuePair<string, object>> parameter1 = new Collection<KeyValuePair<string, object>>(); parameter1.Add(new KeyValuePair<string, object>("@OfficeId", officeId.ToString(CultureInfo.InvariantCulture))); parameter1.Add(new KeyValuePair<string, object>("@AccountNumber", accountNumber)); Collection<KeyValuePair<string, object>> parameter2 = new Collection<KeyValuePair<string, object>>(); parameter2.Add(new KeyValuePair<string, object>("@From", from)); parameter2.Add(new KeyValuePair<string, object>("@To", to)); parameter2.Add(new KeyValuePair<string, object>("@UserId", userId.ToString(CultureInfo.InvariantCulture))); parameter2.Add(new KeyValuePair<string, object>("@AccountNumber", accountNumber)); parameter2.Add(new KeyValuePair<string, object>("@OfficeId", officeId.ToString(CultureInfo.InvariantCulture))); using (WebReport report = new WebReport()) { report.AddParameterToCollection(parameter1); report.AddParameterToCollection(parameter2); report.RunningTotalText = Titles.RunningTotal; report.Path = "~/Modules/Finance/Reports/Source/Transactions.AccountStatement.xml"; report.AutoInitialize = true; this.Placeholder1.Controls.Add(report); } }
public IEnumerable<Instruction> Hydrate(IEnumerable<Instruction> nodes) { var processedNodes = new Collection<Instruction>(); var skipNext = false; foreach (var xamlNode in nodes) { var matchedInflatable = GetMatchedInflatable(xamlNode); if (matchedInflatable != null) { var toAdd = ReadNodes(xamlNode.XamlType.UnderlyingType); var croppedNodes = Crop(toAdd, xamlNode.XamlType, TypeSource.GetByType((matchedInflatable))); foreach (var croppedNode in croppedNodes) { processedNodes.Add(croppedNode); skipNext = true; } } else { if (skipNext) { skipNext = false; } else { processedNodes.Add(xamlNode); } } } return processedNodes; }
private static void AddCollectionCode(PropertyDefinition property, bool isFirst, Collection<Instruction> ins, VariableDefinition resultVariable, MethodDefinition method, TypeDefinition type) { if (isFirst) { ins.Add(Instruction.Create(OpCodes.Ldc_I4_0)); ins.Add(Instruction.Create(OpCodes.Stloc, resultVariable)); } ins.If( c => { LoadVariable(property, c, type); }, t => { LoadVariable(property, t, type); var enumeratorVariable = method.Body.Variables.Add(property.Name + "Enumarator", ReferenceFinder.IEnumerator.TypeReference); var currentVariable = method.Body.Variables.Add(property.Name + "Current", ReferenceFinder.Object.TypeReference); GetEnumerator(t, enumeratorVariable); AddCollectionLoop(resultVariable, t, enumeratorVariable, currentVariable); }, f => { }); }
public void Collapse_TaskCollection_A_ReturnsCorrectEnumerable() { // Arrange var taskCollection = new Collection<ITask>(); DateTime t1 = DateTime.Now; DateTime t2 = t1.AddHours(1); DateTime t3 = t1.AddHours(2); DateTime t4 = t1.AddHours(3); // 1----2----3----4 taskCollection.Add(Task.CreateUsingQuantityPerHour(t1, t3, 100F)); // +---------+ taskCollection.Add(Task.CreateUsingQuantityPerHour(t2, t4, 200F)); // +---------+ taskCollection.Add(Task.CreateUsingQuantityPerHour(t2, t3, -300F)); // +----+ taskCollection.Add(Task.CreateUsingQuantityPerHour(t2, t3, 100F)); // +----+ // Act IEnumerable<ITask> tasks = taskCollection.Collapse(); // Assert var tasksCorrect = new Collection<ITask>(); // 1----2----3----4 tasksCorrect.Add(Task.CreateUsingQuantityPerHour(t1, t2, 100F)); // +----+ tasksCorrect.Add(Task.CreateUsingQuantityPerHour(t2, t3, 100F)); // +----+ tasksCorrect.Add(Task.CreateUsingQuantityPerHour(t3, t4, 200F)); // +----+ Assert.AreEqual(tasksCorrect, tasks); }
public void Linestring() { LineString l = new LineString(); Assert.IsTrue(l.IsEmpty()); Assert.IsNull(l.GetBoundingBox()); Assert.AreEqual(0, l.Length); Assert.IsFalse(l.Equals(null)); Assert.IsTrue(l.Equals(new LineString())); Collection<Point> vertices = new Collection<Point>(); vertices.Add(new Point(54, 23)); vertices.Add(new Point(93, 12)); vertices.Add(new Point(104, 32)); l.Vertices = vertices; Assert.IsFalse(l.IsEmpty()); Assert.IsFalse(l.IsClosed); Assert.AreEqual(3, l.NumPoints); Assert.AreEqual(new Point(54, 23), l.StartPoint); Assert.AreEqual(new Point(104,32), l.EndPoint); l.Vertices.Add(new Point(54, 23)); Assert.IsTrue(l.IsClosed); Assert.AreEqual(114.15056678325843, l.Length); Assert.AreNotSame(l.Clone(), l); Assert.AreNotSame(l.Clone().Vertices[0], l.Vertices[0]); Assert.AreEqual(l.Clone(), l); LineString l2 = l.Clone(); l2.Vertices[2] = l2.Vertices[2] + new Point(1, 1); Assert.AreNotEqual(l2, l); l2 = l.Clone(); l2.Vertices.Add(new Point(34, 23)); Assert.AreNotEqual(l2, l); }
public void Generate_WithMultipleOutParameters() { string functionName = "FunctionWithOuts"; Collection<ParameterDescriptor> parameters = new Collection<ParameterDescriptor>(); parameters.Add(new ParameterDescriptor("param1", typeof(string))); parameters.Add(new ParameterDescriptor("param2", typeof(string).MakeByRefType()) { Attributes = ParameterAttributes.Out }); parameters.Add(new ParameterDescriptor("param3", typeof(string).MakeByRefType()) { Attributes = ParameterAttributes.Out }); FunctionMetadata metadata = new FunctionMetadata(); TestInvoker invoker = new TestInvoker(); FunctionDescriptor function = new FunctionDescriptor(functionName, invoker, metadata, parameters); Collection<FunctionDescriptor> functions = new Collection<FunctionDescriptor>(); functions.Add(function); // generate the Type Type functionType = FunctionGenerator.Generate("TestScriptHost", "TestFunctions", functions); // verify the generated function MethodInfo method = functionType.GetMethod(functionName); ParameterInfo[] functionParams = method.GetParameters(); // Verify that we have the correct number of parameters Assert.Equal(parameters.Count, functionParams.Length); // Verify that out parameters were correctly generated Assert.True(functionParams[1].IsOut); Assert.True(functionParams[2].IsOut); // Verify that the method is invocable method.Invoke(null, new object[] { "test", null, null }); // verify our custom invoker was called Assert.Equal(1, invoker.InvokeCount); }
/// <summary> /// 插入角色信息 /// </summary> /// <param name="cInfo"></param> /// <returns></returns> public bool Insert(Character cInfo) { string sqlcmd = @"INSERT INTO {0} ( CHARACTER_NO ,CHARACTER_NAME ,ANIME_NO ,CV_ID ,LEADING_FLG ,ENABLE_FLG ,LAST_UPDATE_DATETIME ) VALUES ( @characterNo ,@charactername ,@animeNo ,@CVID ,@leadingFlg ,1 ,GETDATE() )"; Collection<DbParameter> paras = new Collection<DbParameter>(); paras.Add(new SqlParameter("@characterNo", cInfo.No)); paras.Add(new SqlParameter("@charactername", cInfo.name)); paras.Add(new SqlParameter("@animeNo", cInfo.animeNo)); paras.Add(new SqlParameter("@CVID", cInfo.CVID)); paras.Add(new SqlParameter("@leadingFlg", cInfo.leadingFLG)); DbCmd.DoCommand(string.Format(sqlcmd, CommonConst.TableName.T_CHARACTER_TBL), paras); return true; }
public IssuedTokensHeader(XmlReader xmlReader, MessageVersion version, SecurityStandardsManager standardsManager) { if (xmlReader == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("xmlReader"); } if (standardsManager == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("standardsManager")); } this.standardsManager = standardsManager; XmlDictionaryReader reader = XmlDictionaryReader.CreateDictionaryReader(xmlReader); MessageHeader.GetHeaderAttributes(reader, version, out this.actor, out this.mustUnderstand, out this.relay, out this.isRefParam); reader.ReadStartElement(this.Name, this.Namespace); Collection<RequestSecurityTokenResponse> list = new Collection<RequestSecurityTokenResponse>(); if (this.standardsManager.TrustDriver.IsAtRequestSecurityTokenResponseCollection(reader)) { foreach (RequestSecurityTokenResponse response in this.standardsManager.TrustDriver.CreateRequestSecurityTokenResponseCollection(reader).RstrCollection) { list.Add(response); } } else { RequestSecurityTokenResponse item = this.standardsManager.TrustDriver.CreateRequestSecurityTokenResponse(reader); list.Add(item); } this.tokenIssuances = new ReadOnlyCollection<RequestSecurityTokenResponse>(list); reader.ReadEndElement(); }
public override void OnControlLoad(object sender, EventArgs e) { string itemCode = this.Page.Request["ItemCode"]; DateTime from = Conversion.TryCastDate(this.Page.Request["From"]); DateTime to = Conversion.TryCastDate(this.Page.Request["To"]); int storeId = Conversion.TryCastInteger(this.Page.Request["StoreId"]); int userId = AppUsers.GetCurrent().View.UserId.ToInt(); Collection<KeyValuePair<string, object>> parameter1 = new Collection<KeyValuePair<string, object>>(); parameter1.Add(new KeyValuePair<string, object>("@ItemCode", itemCode)); Collection<KeyValuePair<string, object>> parameter2 = new Collection<KeyValuePair<string, object>>(); parameter2.Add(new KeyValuePair<string, object>("@From", from)); parameter2.Add(new KeyValuePair<string, object>("@To", to)); parameter2.Add(new KeyValuePair<string, object>("@UserId", userId.ToString(CultureInfo.InvariantCulture))); parameter2.Add(new KeyValuePair<string, object>("@ItemCode", itemCode)); parameter2.Add(new KeyValuePair<string, object>("@StoreId", storeId.ToString(CultureInfo.InvariantCulture))); using (WebReport report = new WebReport()) { report.AddParameterToCollection(parameter1); report.AddParameterToCollection(parameter2); report.RunningTotalText = Titles.RunningTotal; report.Path = "~/Modules/Inventory/Reports/Source/Inventory.AccountStatement.xml"; report.AutoInitialize = true; this.Controls.Add(report); } }
private static ICollection<IServiceBehavior> CreateServiceBehaviors() { ICollection<IServiceBehavior> serviceBehaviors = new Collection<IServiceBehavior>(); serviceBehaviors.Add(new UnityServiceBehavior()); serviceBehaviors.Add(new NHibernateUnitOfWorkServiceBehavior()); return serviceBehaviors; }
public static IEnumerable<string> ExecutePowershellCommand(this Robot robot, string command) { var host = new MMBotHost(robot); using (var runspace = RunspaceFactory.CreateRunspace(host)) { runspace.Open(); using (var invoker = new RunspaceInvoke(runspace)) { Collection<PSObject> psObjects = new Collection<PSObject>(); try { IList errors; psObjects = invoker.Invoke(command, null, out errors); if (errors.Count > 0) { string errorString = string.Empty; foreach (var error in errors) errorString += error.ToString(); psObjects.Add(new PSObject(errorString)); } } catch (Exception ex) { psObjects.Add(new PSObject(ex.Message)); } foreach (var psObject in psObjects) { yield return psObject.ConvertToString(); } } } }
internal override Collection<CommandParameterInternal> BindParameters(Collection<CommandParameterInternal> arguments) { Collection<CommandParameterInternal> collection = new Collection<CommandParameterInternal>(); foreach (CommandParameterInternal internal2 in arguments) { if (!internal2.ParameterNameSpecified) { collection.Add(internal2); } else { MergedCompiledCommandParameter parameter = base.BindableParameters.GetMatchingParameter(internal2.ParameterName, false, true, new InvocationInfo(base.InvocationInfo.MyCommand, internal2.ParameterExtent)); if (parameter != null) { if (base.BoundParameters.ContainsKey(parameter.Parameter.Name)) { ParameterBindingException exception = new ParameterBindingException(ErrorCategory.InvalidArgument, base.InvocationInfo, base.GetParameterErrorExtent(internal2), internal2.ParameterName, null, null, "ParameterBinderStrings", "ParameterAlreadyBound", new object[0]); throw exception; } this.BindParameter(int.MaxValue, internal2, parameter, ParameterBindingFlags.ShouldCoerceType); } else if (internal2.ParameterName.Equals("-%", StringComparison.Ordinal)) { base.DefaultParameterBinder.CommandLineParameters.SetImplicitUsingParameters(internal2.ArgumentValue); } else { collection.Add(internal2); } } } return collection; }
protected static object GetHandler(Type requestType, SingleInstanceFactory singleInstanceFactory, ref Collection <Exception> resolveExceptions) { try { return(singleInstanceFactory(requestType)); } catch (Exception e) { resolveExceptions?.Add(e); return(null); } }
public IHttpActionResult GetTasks() { Collection <TaskModel> tasks = new Collection <TaskModel>(); var blTasks = _taskManagerBL?.GetTask(); blTasks?.ToList().ForEach( x => tasks?.Add( new TaskModel { TaskID = x.TaskID, Task = x.Task, ParentTask = x.ParentTask ?? "", Priority = x.Priority, StartDate = x.StartDate, EndDate = x.EndDate, IsActive = x.IsActive })); return(Ok(tasks)); }
internal void InternalAdd(MulticastIPAddressInformation address) { addresses.Add(address); }
public override void GetParentRealUIds(Collection <Guid> realUIds) { base.GetParentRealUIds(realUIds); realUIds.Add(new Guid("2433ee1c-d882-476a-aa3e-688dee2b58c1")); }
public override void GetParentRealUIds(Collection <Guid> realUIds) { base.GetParentRealUIds(realUIds); realUIds.Add(new Guid("e84b53dc-e950-4b65-a1bb-27628a913a61")); }
void CreateImplementation() { this.bodyClone = Activator.CreateInstance(this.Body.GetType()) as Activity; foreach (PropertyInfo pi in this.Body.GetType().GetProperties()) { if (pi.CanWrite) { pi.SetValue(this.bodyClone, pi.GetValue(this.Body, null), null); } if (pi.PropertyType.IsGenericType) { Type argType = pi.PropertyType.GetGenericArguments()[0]; Type exprRefType = typeof(VisualBasicReference <>).MakeGenericType(argType); Type exprValueType = typeof(VisualBasicValue <>).MakeGenericType(argType); if (pi.PropertyType.GetGenericTypeDefinition() == typeof(InArgument <>)) { // only expose InArguments that haven't already been bound if (pi.GetValue(this.Body, null) == null) { // create the Variable and add it internally string variableName = pi.Name; Variable var = Variable.Create(variableName, argType, VariableModifiers.None); this.variables.Add(var); // create the OutArgument by calling the VisualBasicReference<>(string expressionText) constructor and set it on the Receive OutArgument outArg = Argument.Create(argType, ArgumentDirection.Out) as OutArgument; outArg.Expression = (ActivityWithResult)Activator.CreateInstance(exprRefType, variableName); ((ReceiveParametersContent)receive.Content).Parameters.Add(pi.Name, outArg); // create the InArgument by calling the VisualBasicReference<>(string expressionText) constructor and set it to the Variable InArgument inArg = Argument.Create(argType, ArgumentDirection.In) as InArgument; inArg.Expression = (ActivityWithResult)Activator.CreateInstance(exprValueType, variableName); pi.SetValue(this.bodyClone, inArg, null); } } else if (pi.PropertyType.GetGenericTypeDefinition() == typeof(OutArgument <>)) { // create the Variable and add it internally string variableName = pi.Name; Variable var = Variable.Create(variableName, argType, VariableModifiers.None); this.variables.Add(var); if (pi.GetValue(this.Body, null) != null) { // copy the OutArgument OutArgument refOutArg = ((OutArgument)pi.GetValue(this.Body, null)); string temp = refOutArg.Expression.ResultType.ToString(); InArgument assignInArg = Argument.Create(argType, ArgumentDirection.In) as InArgument; assignInArg.Expression = (ActivityWithResult)Activator.CreateInstance(exprValueType, variableName); Assign a = new Assign { To = refOutArg, //To = OutArgument.CreateReference(varRef, pi.Name), Value = assignInArg }; assigns.Add(a); } // create an OutArgument by calling the VisualBasicReference<>(string expressionText) constructor and set it to the Variable OutArgument outArg = Argument.Create(argType, ArgumentDirection.Out) as OutArgument; outArg.Expression = (ActivityWithResult)Activator.CreateInstance(exprRefType, variableName); pi.SetValue(this.bodyClone, outArg, null); // create the InArgument by calling the VisualBasicReference<>(string expressionText) constructor and set it on the SendReply InArgument inArg = Argument.Create(argType, ArgumentDirection.In) as InArgument; inArg.Expression = (ActivityWithResult)Activator.CreateInstance(exprValueType, variableName); ((SendParametersContent)reply.Content).Parameters.Add(variableName, inArg); } } } // create internal Sequence and add the variables impl = new Sequence(); foreach (Variable v in this.variables) { impl.Variables.Add(v); } // add the Receive receive.CanCreateInstance = this.CanCreateInstance; receive.OperationName = (this.DisplayName != "OperationScope" ? this.DisplayName : this.Body.DisplayName); impl.Activities.Add(receive); // add the activity which represents the operation body impl.Activities.Add(this.bodyClone); // add the Reply impl.Activities.Add(reply); // add any other Assigns to OutArguments foreach (Assign assignToOutArg in this.assigns) { impl.Activities.Add(assignToOutArg); } }
internal HttpResponseMessage DownTimeDates(HttpRequestMessage request, DownTimeDTO cqDTO) { string key; var aur = new AppUserRepository(); var companyId = 0; var userId = aur.ValidateUser(cqDTO.Key, out key, ref companyId); if (userId > 0) { var ur = new DownTimeRepository(); var u = new DownTime(); if (cqDTO.DownTimeDate != null) { cqDTO.Start_DownTimeDate = DateTime.Parse(cqDTO.DownTimeDate).ToString(); cqDTO.End_DownTimeDate = DateTime.Parse(cqDTO.DownTimeDate).AddDays(1).ToString(); } else { int sm = int.Parse(cqDTO.StartDateMonth); if (sm == 1) { cqDTO.Start_DownTimeDate = DateTime.Parse("12/23/" + (int.Parse(cqDTO.StartDateYear) - 1).ToString()).ToString(); cqDTO.End_DownTimeDate = DateTime.Parse("2/14/" + cqDTO.StartDateYear).ToString(); } else if (sm == 12) { cqDTO.Start_DownTimeDate = DateTime.Parse("11/23/" + cqDTO.StartDateYear).ToString(); cqDTO.End_DownTimeDate = DateTime.Parse("1/14/" + (int.Parse(cqDTO.StartDateYear) + 1).ToString()).ToString(); } else { cqDTO.Start_DownTimeDate = DateTime.Parse((int.Parse(cqDTO.StartDateMonth) - 1).ToString() + "/23/" + cqDTO.StartDateYear).ToString(); cqDTO.End_DownTimeDate = DateTime.Parse((int.Parse(cqDTO.StartDateMonth) + 1).ToString() + "/14/" + cqDTO.StartDateYear).ToString(); } cqDTO.StartDateMonth = null; cqDTO.StartDateYear = null; } var predicate = ur.GetPredicate(cqDTO, u, companyId); var data = ur.GetByPredicate(predicate); var col = new Collection <Dictionary <string, string> >(); data = data.GroupBy(x => x.DownTimeDate).Select(x => x.First()).OrderBy(x => x.DownTimeDate).ToList(); foreach (var item in data) { var dic = new Dictionary <string, string>(); dic.Add("DownTimeDate", item.DownTimeDate.ToShortDateString()); col.Add(dic); var ufdic = new Dictionary <string, string>(); } var retVal = new GenericDTO { Key = key, ReturnData = col }; return(Request.CreateResponse(HttpStatusCode.OK, retVal)); } var message = "validation failed"; return(request.CreateResponse(HttpStatusCode.NotFound, message)); }
public override void GetParentRealUIds(Collection <Guid> realUIds) { base.GetParentRealUIds(realUIds); realUIds.Add(new Guid("8c7d4b80-e88d-46bb-b276-9e7a4f4b69e3")); }
public void AddSearchDirectory(string directory) { directories.Add(directory); }
public override void GetParentRealUIds(Collection <Guid> realUIds) { base.GetParentRealUIds(realUIds); realUIds.Add(new Guid("a278cc45-88fd-4a7c-b68b-f2b7fd355781")); }
public override void GetParentRealUIds(Collection <Guid> realUIds) { base.GetParentRealUIds(realUIds); realUIds.Add(new Guid("5b4fa189-8f4e-44e7-b0b9-2bb16ed96ab6")); }
public override void GetParentRealUIds(Collection <Guid> realUIds) { base.GetParentRealUIds(realUIds); realUIds.Add(new Guid("2aecdb97-990e-4c17-96f4-240ca6531c84")); }
/// <summary> /// 添加模型 /// </summary> /// <param name="model">加入的模板</param> /// <returns></returns> public void AddModel(EmrModel model) { m_nodes.Add(model); }
public override void GetParentRealUIds(Collection <Guid> realUIds) { base.GetParentRealUIds(realUIds); realUIds.Add(new Guid("1e337b8d-0013-4c23-87df-2e46aad2b9c1")); }
public override void GetParentRealUIds(Collection <Guid> realUIds) { base.GetParentRealUIds(realUIds); realUIds.Add(new Guid("e61dae9a-2655-48a6-bc4a-42efa1e9c942")); }
public override void GetParentRealUIds(Collection <Guid> realUIds) { base.GetParentRealUIds(realUIds); realUIds.Add(new Guid("88e0be6b-543f-42a7-9c74-8a6542583cb1")); }
public override void GetParentRealUIds(Collection <Guid> realUIds) { base.GetParentRealUIds(realUIds); realUIds.Add(new Guid("09b7ef42-786a-4312-aaf7-30d4570ffd41")); }
/// <summary> /// Adds pssnapins to console file and loads the pssnapin dlls into /// the current monad runtime. /// </summary> /// <remarks> /// The new pssnapin information is not stored in the console file until /// the file is saved. /// </remarks> protected override void ProcessRecord() { // Cache for the information stored in the registry // update the cache the first time a wildcard is found.. Collection <PSSnapInInfo> listToSearch = null; foreach (string pattern in _pssnapins) { Exception exception = null; Collection <string> listToAdd = new Collection <string>(); try { // check whether there are any wildcard characters bool doWildCardSearch = WildcardPattern.ContainsWildcardCharacters(pattern); if (doWildCardSearch) { // wildcard found in the pattern // Get all the possible candidates for current monad version if (listToSearch == null) { // cache snapin registry information... // For 3.0 PowerShell, we still use "1" as the registry version key for // Snapin and Custom shell lookup/discovery. // For 3.0 PowerShell, we use "3" as the registry version key only for Engine // related data like ApplicationBase etc. listToSearch = PSSnapInReader.ReadAll(PSVersionInfo.RegistryVersion1Key); } listToAdd = SearchListForPattern(listToSearch, pattern); // listToAdd wont be null.. Diagnostics.Assert(listToAdd != null, "Pattern matching returned null"); if (listToAdd.Count == 0) { if (_passThru) { // passThru is specified and we have nothing to add... WriteNonTerminatingError(pattern, "NoPSSnapInsFound", PSTraceSource.NewArgumentException(pattern, MshSnapInCmdletResources.NoPSSnapInsFound, pattern), ErrorCategory.InvalidArgument); } continue; } } else { listToAdd.Add(pattern); } // now add all the snapins for this pattern... AddPSSnapIns(listToAdd); } catch (PSArgumentException ae) { exception = ae; } catch (System.Security.SecurityException se) { exception = se; } if (exception != null) { WriteNonTerminatingError(pattern, "AddPSSnapInRead", exception, ErrorCategory.InvalidArgument); } } }
public override void GetParentRealUIds(Collection <Guid> realUIds) { base.GetParentRealUIds(realUIds); realUIds.Add(new Guid("54be68f8-96c2-4418-b83b-286c226c0ac4")); }
/// <summary> /// Routine to get the list of loaded snapins... /// </summary> /// <returns></returns> protected internal Collection <PSSnapInInfo> GetSnapIns(string pattern) { // If RunspaceConfiguration is not null, then return the list that it has if (Runspace != null) { if (pattern != null) { return(Runspace.ConsoleInfo.GetPSSnapIn(pattern, _shouldGetAll)); } else { return(Runspace.ConsoleInfo.PSSnapIns); } } WildcardPattern matcher = null; if (!String.IsNullOrEmpty(pattern)) { bool doWildCardSearch = WildcardPattern.ContainsWildcardCharacters(pattern); if (!doWildCardSearch) { // Verify PSSnapInID.. // This will throw if it not a valid name PSSnapInInfo.VerifyPSSnapInFormatThrowIfError(pattern); } matcher = WildcardPattern.Get(pattern, WildcardOptions.IgnoreCase); } Collection <PSSnapInInfo> snapins = new Collection <PSSnapInInfo>(); if (_shouldGetAll) { foreach (PSSnapInInfo snapinKey in PSSnapInReader.ReadAll()) { if (matcher == null || matcher.IsMatch(snapinKey.Name)) { snapins.Add(snapinKey); } } } else { // Otherwise, just scan through the list of cmdlets and rebuild the table. List <CmdletInfo> cmdlets = InvokeCommand.GetCmdlets(); Dictionary <PSSnapInInfo, bool> snapinTable = new Dictionary <PSSnapInInfo, bool>(); foreach (CmdletInfo cmdlet in cmdlets) { PSSnapInInfo snapin = cmdlet.PSSnapIn; if (snapin != null && !snapinTable.ContainsKey(snapin)) { snapinTable.Add(snapin, true); } } foreach (PSSnapInInfo snapinKey in snapinTable.Keys) { if (matcher == null || matcher.IsMatch(snapinKey.Name)) { snapins.Add(snapinKey); } } } return(snapins); }
public override void GetParentRealUIds(Collection <Guid> realUIds) { base.GetParentRealUIds(realUIds); realUIds.Add(new Guid("85811a1d-f704-4381-b169-eeb0ca280754")); }
public override void GetParentRealUIds(Collection <Guid> realUIds) { base.GetParentRealUIds(realUIds); realUIds.Add(new Guid("7168866e-bf9a-4c7d-a71f-006687219c1e")); }
/// <summary> /// Resolves the specified paths to PathInfo objects. /// </summary> /// <param name="pathsToResolve"> /// The paths to be resolved. Each path may contain glob characters. /// </param> /// <param name="allowNonexistingPaths"> /// If true, resolves the path even if it doesn't exist. /// </param> /// <param name="allowEmptyResult"> /// If true, allows a wildcard that returns no results. /// </param> /// <param name="currentCommandContext"> /// The context under which the command is running. /// </param> /// <returns> /// An array of PathInfo objects that are the resolved paths for the /// <paramref name="pathsToResolve"/> parameter. /// </returns> internal Collection <PathInfo> ResolvePaths( string[] pathsToResolve, bool allowNonexistingPaths, bool allowEmptyResult, CmdletProviderContext currentCommandContext) { Collection <PathInfo> results = new Collection <PathInfo>(); foreach (string path in pathsToResolve) { bool pathNotFound = false; bool filtersHidPath = false; ErrorRecord pathNotFoundErrorRecord = null; try { // First resolve each of the paths Collection <PathInfo> pathInfos = SessionState.Path.GetResolvedPSPathFromPSPath( path, currentCommandContext); if (pathInfos.Count == 0) { pathNotFound = true; // If the item simply did not exist, // we would have got an ItemNotFoundException. // If we get here, it's because the filters // excluded the file. if (!currentCommandContext.SuppressWildcardExpansion) { filtersHidPath = true; } } foreach (PathInfo pathInfo in pathInfos) { results.Add(pathInfo); } } catch (PSNotSupportedException notSupported) { WriteError( new ErrorRecord( notSupported.ErrorRecord, notSupported)); } catch (DriveNotFoundException driveNotFound) { WriteError( new ErrorRecord( driveNotFound.ErrorRecord, driveNotFound)); } catch (ProviderNotFoundException providerNotFound) { WriteError( new ErrorRecord( providerNotFound.ErrorRecord, providerNotFound)); } catch (ItemNotFoundException pathNotFoundException) { pathNotFound = true; pathNotFoundErrorRecord = new ErrorRecord(pathNotFoundException.ErrorRecord, pathNotFoundException); } if (pathNotFound) { if (allowNonexistingPaths && (!filtersHidPath) && (currentCommandContext.SuppressWildcardExpansion || (!WildcardPattern.ContainsWildcardCharacters(path)))) { ProviderInfo provider = null; PSDriveInfo drive = null; string unresolvedPath = SessionState.Path.GetUnresolvedProviderPathFromPSPath( path, currentCommandContext, out provider, out drive); PathInfo pathInfo = new PathInfo( drive, provider, unresolvedPath, SessionState); results.Add(pathInfo); } else { if (pathNotFoundErrorRecord == null) { // Detect if the path resolution failed to resolve to a file. string error = StringUtil.Format(NavigationResources.ItemNotFound, Path); Exception e = new Exception(error); pathNotFoundErrorRecord = new ErrorRecord( e, "ItemNotFound", ErrorCategory.ObjectNotFound, Path); } WriteError(pathNotFoundErrorRecord); } } } return(results); }
private static bool GetFields(string basePath, string fields, Collection<string> result) { if (!Validate(fields)) { return false; } var parenthesisCount = 0; var firstParenthesis = -1; var pathStart = 0; var parenthesisClosed = false; for (var i = 0; i < fields.Length; i++) { var character = fields[i]; if (parenthesisClosed) { if (character != ',' && character != ')' && character != ' ' && character != '\t') { return false; } } if (character == '(') { if (parenthesisCount == 0) { firstParenthesis = i; } parenthesisCount++; } if (character == ')') { parenthesisCount--; if (parenthesisCount < 0) { return false; } parenthesisClosed = true; } if (character == ',' && parenthesisCount == 0) { if (firstParenthesis > -1) { var newBasePath = PathUtilities.CombinePath(basePath, fields.Substring(pathStart, firstParenthesis - pathStart)); if (!GetFields(newBasePath, fields.Substring(firstParenthesis + 1, i - firstParenthesis - 2), result)) { return false; } } else { result.Add(PathUtilities.CombinePath(basePath, fields.Substring(pathStart, i - pathStart).Trim())); } firstParenthesis = -1; pathStart = i + 1; parenthesisClosed = false; } if (i == fields.Length - 1) { if (parenthesisCount != 0) { return false; } if (firstParenthesis > -1) { var newBasePath = PathUtilities.CombinePath(basePath, fields.Substring(pathStart, firstParenthesis - pathStart)); if (!GetFields(newBasePath, fields.Substring(firstParenthesis + 1, i - firstParenthesis - 1), result)) { return false; } } else { result.Add(PathUtilities.CombinePath(basePath, fields.Substring(pathStart, i - pathStart + 1).Trim())); } } } return true; }
public override void GetParentRealUIds(Collection <Guid> realUIds) { base.GetParentRealUIds(realUIds); realUIds.Add(new Guid("79e58c22-6756-4f35-93bc-da6c46a7c24a")); }
public void AddPoint(PointF point) { freeLine.Add(point); }
public override void GetParentRealUIds(Collection <Guid> realUIds) { base.GetParentRealUIds(realUIds); realUIds.Add(new Guid("59f9566f-7cdf-430b-9867-20206e166fa9")); }
public override void GetParentRealUIds(Collection<Guid> realUIds) { base.GetParentRealUIds(realUIds); realUIds.Add(new Guid("dbf82f63-6b83-4a3a-bf0c-9e269fb22dab")); }
public override void GetParentRealUIds(Collection <Guid> realUIds) { base.GetParentRealUIds(realUIds); realUIds.Add(new Guid("3458e046-06cf-451f-94b2-91d74d1bdd68")); }
public override void GetParentRealUIds(Collection <Guid> realUIds) { base.GetParentRealUIds(realUIds); realUIds.Add(new Guid("ca400a85-ec48-4b42-8e50-271929d27871")); }