public AttributeCollection FetchAll() { AttributeCollection coll = new AttributeCollection(); Query qry = new Query(Attribute.Schema); coll.LoadAndCloseReader(qry.ExecuteReader()); return coll; }
public void CollectionSyncProperties() { AttributeCollection collection = new AttributeCollection(null); Assert.Null(((ICollection)collection).SyncRoot); Assert.False(((ICollection)collection).IsSynchronized); }
private PolicyDocumentEntity importFile(baseData vData,string title, string filepath) { AttributeCollection acoll = new AttributeCollection(); acoll.GetMulti(AttributeFields.Name == "Literal"); if (acoll.Count == 0) throw new Exception("can't find literal attribute"); m_literalAttribute = acoll[0]; XmlDocument doc = new XmlDocument(); doc.Load(filepath); PolicyDocumentEntity pde = new PolicyDocumentEntity(); pde.LibraryId = vData.Library.Id; pde.Name = title; PolicyLinkEntity ple = new PolicyLinkEntity(); ple.Policy = new PolicyEntity(); ple.Policy.LibraryId = pde.LibraryId; pde.PolicyLink = ple; XmlNode policySet = doc.SelectSingleNode("policy-set"); if (policySet != null) loadPolicySet(1,title,ple,policySet); else { XmlNode policy = doc.SelectSingleNode("policy"); loadPolicy(1,title,ple,policy); } pde.Save(true); return pde; }
public void TestNoSiblingsFound() { string namespaceUri = "namespaceUri"; string localName = "localname"; string qualifiedName = "qualifiedname"; Mock<IElement> parent = null; IList<IElement> children = new List<IElement>(); AttributeCollection attributes = new AttributeCollection(); Element element = new Element(namespaceUri, localName, qualifiedName, parent as IElement, children, attributes); Assert.IsNull(element.PreviousSibling); namespaceUri = "namespaceUri"; localName = "localname"; qualifiedName = "qualifiedname"; parent = new Mock<IElement>(); children = new List<IElement>(); attributes = new AttributeCollection(); element = new Element(namespaceUri, localName, qualifiedName, parent as IElement, children, attributes); IList<IElement> parentChildren = new List<IElement>(); parent.Setup(c => c.ChildElements).Returns(parentChildren); var previousSiblingStub = new Mock<IElement>(); parentChildren.Add(element); Assert.IsNull(element.PreviousSibling); }
public static IFormatter CreateFormatter(this ScriptScope scriptScope, string className, AttributeCollection attributes) { if (scriptScope.Engine.Setup.Names.Contains("Python")) return new PythonFormatter(className, attributes); return new RubyFormatter(className, attributes); }
/// <summary> /// Initialzies a new instance of Berico.LinkAnalysis.Model.Edge with /// the provided source and target nodes. The source and target nodes /// can not be null and can not be the same. /// </summary> /// <param name="initialWeight">The precalculated weight value</param> /// <param name="_source">The source Node for this edge</param> /// <param name="_target">The target Node for this edge</param> /// <param name="_attributes">An existing AttributeCollection instance</param> public SimilarityDataEdge(double initialWeight, INode _sourceNode, INode _targetNode, AttributeCollection _attributes) : base(_sourceNode, _targetNode, _attributes) { // Set the initial weight. This will be the similarity value that // was calculated before this edge was created this.weight = initialWeight; }
public void TestTextlessConstructor() { string namespaceUri = "namespaceUri"; string localName = "localname"; string qualifiedName = "qualifiedname"; var parent = new Mock<IElement>(); List<IElement> children = new List<IElement>(); AttributeCollection attributes = new AttributeCollection(); Element element = new Element(namespaceUri, localName, qualifiedName, parent.Object, children, attributes); for (int i = 0; i < 10; i++) { children.Add(new Mock<IElement>() as IElement); } IList<IElement> parentChildren = new List<IElement>(); parent.Setup(c => c.ChildElements).Returns(parentChildren); var previousSiblingStub = new Mock<IElement>(); parentChildren.Add(previousSiblingStub.Object); parentChildren.Add(element); Assert.AreEqual(element.Attributes, attributes); Assert.AreEqual(element.ChildElements, children); Assert.AreEqual(element.FirstElement, children[0]); Assert.IsTrue(element.HasChildNodes); Assert.AreEqual(element.LastElement, children[9]); Assert.AreEqual(element.LocalName, localName); Assert.AreEqual(element.Name, qualifiedName); Assert.AreEqual(element.NamespaceUri, namespaceUri); Assert.AreEqual(element.ParentElement, parent.Object); Assert.AreEqual(element.PreviousSibling, previousSiblingStub.Object); Assert.AreEqual(element.TextContent, string.Empty); }
internal Rule( string name ) { Check.IsNotNullOrWhitespace ( name, () => Name ); Name = name; _attributes = new AttributeCollection (); }
public void TestAddingExistingAttribute() { bool exceptionThrown; AttributeCollection attributes = new AttributeCollection(); AttributeValue newAttributeValue = new AttributeValue("Test Value"); // Add attribute and attribute value attributes.Add("Test", newAttributeValue); Assert.AreEqual<string>(newAttributeValue.Value, attributes["Test"].Value); AttributeValue existingAttributeValue = new AttributeValue("Test Value"); try { attributes.Add("Test", existingAttributeValue); exceptionThrown = false; } catch (ArgumentException) { exceptionThrown = true; } Assert.IsTrue(exceptionThrown); }
/// <summary> 表示一个可以获取或者设置其内容的对象属性 /// </summary> /// <param name="property">属性信息</param> public ObjectProperty(PropertyInfo property) { Field = false; MemberInfo = property; //属性信息 OriginalType = property.PropertyType; var get = property.GetGetMethod(true); //获取属性get方法,不论是否公开 var set = property.GetSetMethod(true); //获取属性set方法,不论是否公开 if (set != null) //set方法不为空 { CanWrite = true; //属性可写 Static = set.IsStatic; //属性是否为静态属性 IsPublic = set.IsPublic; } if (get != null) //get方法不为空 { CanRead = true; //属性可读 Static = get.IsStatic; //get.set只要有一个静态就是静态 IsPublic = IsPublic || get.IsPublic; } ID = System.Threading.Interlocked.Increment(ref Literacy.Sequence); UID = Guid.NewGuid(); Init(); TypeCodes = TypeInfo.TypeCodes; Attributes = new AttributeCollection(MemberInfo); var mapping = Attributes.First<IMemberMappingAttribute>(); if (mapping != null) { MappingName = mapping.Name; } }
public void TestParse() { var saxHandler = new Mock<ISaxHandler>(); using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream()) { memoryStream.Write(new System.Text.UTF8Encoding().GetBytes(_xmlToParse), 0, _xmlToParse.Length); memoryStream.Position = 0; SaxReaderImpl saxReaderImpl = new SaxReaderImpl(); saxReaderImpl.Parse(new System.IO.StreamReader(memoryStream), saxHandler.Object); } AttributeCollection element3Attributes = new AttributeCollection(); Attribute attr1Attribute = new Attribute(); attr1Attribute.LocalName = "attr1"; attr1Attribute.QName = "attr1"; attr1Attribute.Uri = string.Empty; attr1Attribute.Value = "val1"; element3Attributes.Add("attr1", attr1Attribute); saxHandler.Verify(c => c.StartDocument(), Times.Exactly(1)); saxHandler.Verify(c => c.EndDocument(), Times.Exactly(1)); saxHandler.Verify(c => c.StartElement(string.Empty, "root", "root", new AttributeCollection())); saxHandler.Verify(c => c.StartElement(string.Empty, "element1", "element1", new AttributeCollection())); saxHandler.Verify(c => c.StartElement(string.Empty, "element2", "element2", new AttributeCollection())); saxHandler.Verify(c => c.StartElement(string.Empty, "element3", "element3", element3Attributes)); saxHandler.Verify(c => c.EndElement(string.Empty, "root", "root")); saxHandler.Verify(c => c.EndElement(string.Empty, "element1", "element1")); saxHandler.Verify(c => c.EndElement(string.Empty, "element2", "element2")); saxHandler.Verify(c => c.EndElement(string.Empty, "element3", "element3")); saxHandler.Verify(c => c.Characters(It.IsAny<char[]>(), It.IsAny<int>(), It.IsAny<int>())); }
public static AttributeCollection Merge(this AttributeCollection left, AttributeCollection right) { var result = new AttributeCollection { Base = left.Base.Merge(right.Base), Mult = left.Mult.Merge(right.Mult) }; return result; }
public Element(string name, string text, params IAttribute[] attributes) { this._Name = name; this._Attributes = new AttributeCollection(attributes); this._Children = new NodeCollection(new Text(text)); }
public void ContainsKey_SendInDictionaryWithStringKeyAndObjectArrayValueAndCheckForKey_ReturnsTrue() { var attributeValueCollection = A.CollectionOfFake<object>(1); var dictionary = new Hashtable(); dictionary.Add("key", attributeValueCollection); var collection = new AttributeCollection(dictionary); Assert.IsTrue(collection.ContainsKey("key")); }
private void EnsureAttributes () { if (attributes == null) { attrBag = new StateBag (true); if (IsTrackingViewState) attrBag.TrackViewState (); attributes = new AttributeCollection (attrBag); } }
public void Index_SendInDictionaryWithStringKeyAndObjectArrayValue_IndexWithKeyContainsValue() { var attributeValueCollection = A.CollectionOfFake<object>(1); var dictionary = new Hashtable(); dictionary.Add("key", attributeValueCollection); var collection = new AttributeCollection(dictionary); Assert.AreEqual(attributeValueCollection, collection["key"]); }
public static AttributeCollection Apply(AttributeCollection attributes) { AttributeCollection result = new AttributeCollection().Merge(attributes); foreach (var formula in _formulas) { result.Base [formula.Key] = result.Base.TryGetValue (formula.Key).GetValueOrDefault (0) + formula.Value (result); } return result; }
public void TestAddingAttributeWithValue() { AttributeCollection attributes = new AttributeCollection(); AttributeValue comparisonAttributeValue = new AttributeValue("Value"); attributes.Add("Name", comparisonAttributeValue); Assert.AreEqual<string>(comparisonAttributeValue.Value, attributes["Name"].Value); }
public void Count_SendInDictionaryWithOnePost_ReturnsOne() { var attributeValueCollection = A.CollectionOfFake<object>(1); var dictionary = new Hashtable(); dictionary.Add("key", attributeValueCollection); var collection = new AttributeCollection(dictionary); Assert.AreEqual(1, collection.Count); }
internal DefaultMessageBuffer (int maxBufferSize, MessageHeaders headers, MessageProperties properties, BodyWriter body, bool isFault, AttributeCollection attributes) { this.max_buffer_size = maxBufferSize; this.headers = headers; this.body = body; this.closed = false; this.is_fault = isFault; this.properties = properties; this.attributes = attributes; }
public void CopyTest(int count, int index) { var attributes = GetAttributes().Take(count).ToArray(); var attributeCollection = new AttributeCollection(attributes); var array = new Attribute[count + index]; attributeCollection.CopyTo(array, index); Assert.Equal(attributeCollection.Cast<Attribute>(), array.Cast<Attribute>().Skip(index)); }
public void ContainsTest(int count) { var attributes = GetAttributes().Take(count).ToArray(); var attributeCollection = new AttributeCollection(attributes); foreach (Attribute attribute in attributes) { Assert.True(attributeCollection.Contains(attribute)); } }
public Entity(EntityType entityType) { if (entityType == null) { throw new OperationException(); } EntityType = entityType; Attributes = new AttributeCollection(entityType.Attributes); }
public void WithValueFalseRemovesAttributeIfAlreadyExists() { string attributeName = "AttributeName"; var attributeCollection = new AttributeCollection(); attributeCollection.AddOrRemoveMinimizedAttribute( attributeName, true ); attributeCollection.AddOrRemoveMinimizedAttribute( attributeName, false ); Assert.IsFalse( attributeCollection.ContainsKey( attributeName ) ); }
public void WithValueTrueAddsAttributeCorrectly() { string attributeName = "AttributeName"; bool value = true; var attributeCollection = new AttributeCollection(); attributeCollection.AddOrRemoveMinimizedAttribute( attributeName, value ); Assert.AreEqual( attributeName, attributeCollection[ attributeName ] ); }
public void WithValueFalseDoesNotAddAttribute() { string attributeName = "AttributeName"; bool value = false; var attributeCollection = new AttributeCollection(); attributeCollection.AddOrRemoveMinimizedAttribute( attributeName, value ); Assert.IsFalse( attributeCollection.ContainsKey( attributeName ) ); }
public SelectList allAttributes(object selObjId) { if (m_allAttributes == null) { m_allAttributes = new AttributeCollection(); SortExpression se = new SortExpression(AttributeFields.Name | SortOperator.Ascending); m_allAttributes.GetMulti(null, 0, se); } SelectList selList = new SelectList(m_allAttributes, "Id", "Name", selObjId); return selList; }
public void TestTextConstructor() { string namespaceUri = "namespaceUri"; string localName = "localname"; string qualifiedName = "qualifiedname"; var parent = new Mock<IElement>(); IList<IElement> children = new List<IElement>(); AttributeCollection attributes = new AttributeCollection(); string text = "testing_text_value"; Element element = new Element(namespaceUri, localName, qualifiedName, parent as IElement, children, attributes, text); Assert.AreEqual(element.TextContent, text); }
public override void SetParameters(AttributeCollection parameters) { base.SetParameters(parameters); foreach (var v in parameters.GetValuesForKey("size")) { var min = 0L; if (long.TryParse(v, out min) && min > 0) { minSize = min * 1024 * 1024; break; } } }
public void AddsAttributeCorrectly() { string script = "Script"; var attributes = new AttributeCollection(); var builder = new EventAttributeBuilder( attributes ); var result = builder.OnSubmit( script ); Assert.AreSame( builder, result ); Assert.AreEqual( script, attributes[ HtmlAttributes.Events.OnSubmit ] ); }
/// <summary> /// This serializes the given property on this object. /// </summary> private void SerializeExtenderProperty(IDesignerSerializationManager manager, object value, PropertyDescriptor property, CodeStatementCollection statements) { AttributeCollection attributes = property.Attributes; using (CodeDomSerializer.TraceScope("PropertyMemberCodeDomSerializer::" + nameof(SerializeExtenderProperty))) { ExtenderProvidedPropertyAttribute exAttr = (ExtenderProvidedPropertyAttribute)attributes[typeof(ExtenderProvidedPropertyAttribute)]; // Extender properties are method invokes on a target "extender" object. // CodeExpression extender = SerializeToExpression(manager, exAttr.Provider); CodeExpression extended = SerializeToExpression(manager, value); CodeDomSerializer.TraceWarningIf(extender is null, "Extender object {0} could not be serialized.", manager.GetName(exAttr.Provider)); CodeDomSerializer.TraceWarningIf(extended is null, "Extended object {0} could not be serialized.", manager.GetName(value)); if (extender != null && extended != null) { CodeMethodReferenceExpression methodRef = new CodeMethodReferenceExpression(extender, "Set" + property.Name); object propValue = GetPropertyValue(manager, property, value, out bool validValue); CodeExpression serializedPropertyValue = null; // Serialize the value of this property into a code expression. If we can't get one, // then we won't serialize the property. if (validValue) { ExpressionContext tree = null; if (propValue != value) { // make sure the value isn't the object or we'll end up printing // this property instead of the value. tree = new ExpressionContext(methodRef, property.PropertyType, value); manager.Context.Push(tree); } try { serializedPropertyValue = SerializeToExpression(manager, propValue); } finally { if (tree != null) { Debug.Assert(manager.Context.Current == tree, "Context stack corrupted."); manager.Context.Pop(); } } } if (serializedPropertyValue != null) { CodeMethodInvokeExpression methodInvoke = new CodeMethodInvokeExpression { Method = methodRef }; methodInvoke.Parameters.Add(extended); methodInvoke.Parameters.Add(serializedPropertyValue); statements.Add(methodInvoke); } } } }
/// <summary> /// <para>ProcessControl peforms the high level localization for a single control and optionally it's children.</para> /// </summary> /// <param name="control">Control to find the AttributeCollection on</param> /// <param name="affectedControls">ArrayList that hold the controls that have been localized. This is later used for the removal of the key attribute.</param> /// <param name="includeChildren">If true, causes this method to process children of this controls.</param> /// <param name="resourceFileRoot">Root Resource File.</param> internal void ProcessControl(Control control, ArrayList affectedControls, bool includeChildren, string resourceFileRoot) { if (!control.Visible) { return; } //Perform the substitution if a key was found string key = GetControlAttribute(control, affectedControls, Localization.KeyName); if (!string.IsNullOrEmpty(key)) { //Translation starts here .... string value = Localization.GetString(key, resourceFileRoot); if (control is Label) { var label = (Label)control; if (!String.IsNullOrEmpty(value)) { label.Text = value; } } if (control is LinkButton) { var linkButton = (LinkButton)control; if (!String.IsNullOrEmpty(value)) { MatchCollection imgMatches = Regex.Matches(value, "<(a|link|img|script|input|form).[^>]*(href|src|action)=(\\\"|'|)(.[^\\\"']*)(\\\"|'|)[^>]*>", RegexOptions.IgnoreCase); foreach (Match match in imgMatches) { if ((match.Groups[match.Groups.Count - 2].Value.IndexOf("~", StringComparison.Ordinal) != -1)) { string resolvedUrl = Page.ResolveUrl(match.Groups[match.Groups.Count - 2].Value); value = value.Replace(match.Groups[match.Groups.Count - 2].Value, resolvedUrl); } } linkButton.Text = value; if (string.IsNullOrEmpty(linkButton.ToolTip)) { linkButton.ToolTip = value; } } } if (control is HyperLink) { var hyperLink = (HyperLink)control; if (!String.IsNullOrEmpty(value)) { hyperLink.Text = value; } } if (control is ImageButton) { var imageButton = (ImageButton)control; if (!String.IsNullOrEmpty(value)) { imageButton.AlternateText = value; } } if (control is Button) { var button = (Button)control; if (!String.IsNullOrEmpty(value)) { button.Text = value; } } if (control is HtmlImage) { var htmlImage = (HtmlImage)control; if (!String.IsNullOrEmpty(value)) { htmlImage.Alt = value; } } if (control is CheckBox) { var checkBox = (CheckBox)control; if (!String.IsNullOrEmpty(value)) { checkBox.Text = value; } } if (control is BaseValidator) { var baseValidator = (BaseValidator)control; if (!String.IsNullOrEmpty(value)) { baseValidator.ErrorMessage = value; } } if (control is Image) { var image = (Image)control; if (!String.IsNullOrEmpty(value)) { image.AlternateText = value; image.ToolTip = value; } } } //Translate listcontrol items here if (control is ListControl) { var listControl = (ListControl)control; for (int i = 0; i <= listControl.Items.Count - 1; i++) { AttributeCollection attributeCollection = listControl.Items[i].Attributes; key = attributeCollection[Localization.KeyName]; if (key != null) { string value = Localization.GetString(key, resourceFileRoot); if (!String.IsNullOrEmpty(value)) { listControl.Items[i].Text = value; } } if (key != null && affectedControls != null) { affectedControls.Add(attributeCollection); } } } //UrlRewriting Issue - ResolveClientUrl gets called instead of ResolveUrl //Manual Override to ResolveUrl if (control is Image) { var image = (Image)control; if (image.ImageUrl.IndexOf("~", StringComparison.Ordinal) != -1) { image.ImageUrl = Page.ResolveUrl(image.ImageUrl); } //Check for IconKey if (string.IsNullOrEmpty(image.ImageUrl)) { string iconKey = GetControlAttribute(control, affectedControls, IconController.IconKeyName); string iconSize = GetControlAttribute(control, affectedControls, IconController.IconSizeName); string iconStyle = GetControlAttribute(control, affectedControls, IconController.IconStyleName); image.ImageUrl = IconController.IconURL(iconKey, iconSize, iconStyle); } } //UrlRewriting Issue - ResolveClientUrl gets called instead of ResolveUrl //Manual Override to ResolveUrl if (control is HtmlImage) { var htmlImage = (HtmlImage)control; if (htmlImage.Src.IndexOf("~", StringComparison.Ordinal) != -1) { htmlImage.Src = Page.ResolveUrl(htmlImage.Src); } //Check for IconKey if (string.IsNullOrEmpty(htmlImage.Src)) { string iconKey = GetControlAttribute(control, affectedControls, IconController.IconKeyName); string iconSize = GetControlAttribute(control, affectedControls, IconController.IconSizeName); string iconStyle = GetControlAttribute(control, affectedControls, IconController.IconStyleName); htmlImage.Src = IconController.IconURL(iconKey, iconSize, iconStyle); } } //UrlRewriting Issue - ResolveClientUrl gets called instead of ResolveUrl //Manual Override to ResolveUrl if (control is HyperLink) { HyperLink ctrl; ctrl = (HyperLink)control; if ((ctrl.NavigateUrl.IndexOf("~", StringComparison.Ordinal) != -1)) { ctrl.NavigateUrl = Page.ResolveUrl(ctrl.NavigateUrl); } if ((ctrl.ImageUrl.IndexOf("~", StringComparison.Ordinal) != -1)) { ctrl.ImageUrl = Page.ResolveUrl(ctrl.ImageUrl); } //Check for IconKey if (string.IsNullOrEmpty(ctrl.ImageUrl)) { string iconKey = GetControlAttribute(control, affectedControls, IconController.IconKeyName); string iconSize = GetControlAttribute(control, affectedControls, IconController.IconSizeName); string iconStyle = GetControlAttribute(control, affectedControls, IconController.IconStyleName); ctrl.ImageUrl = IconController.IconURL(iconKey, iconSize, iconStyle); } } //Process child controls if (includeChildren && control.HasControls()) { var objModuleControl = control as IModuleControl; if (objModuleControl == null) { PropertyInfo pi = control.GetType().GetProperty("LocalResourceFile"); if (pi != null && pi.GetValue(control, null) != null) { //If controls has a LocalResourceFile property use this IterateControls(control.Controls, affectedControls, pi.GetValue(control, null).ToString()); } else { //Pass Resource File Root through IterateControls(control.Controls, affectedControls, resourceFileRoot); } } else { //Get Resource File Root from Controls LocalResourceFile Property IterateControls(control.Controls, affectedControls, objModuleControl.LocalResourceFile); } } }
protected TypeMemberImpl(LexicalInfo lexicalInfo, TypeMemberModifiers modifiers, string name) : base(lexicalInfo) { _attributes = new AttributeCollection(this); Modifiers = modifiers; Name = name; }
public virtual AttributeCollection GetAttributes() { AttributeCollection col = TypeDescriptor.GetAttributes(this, true); return(col); }
private void ButtonSelect_Click(object sender, RoutedEventArgs e) { Document acDoc = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument; Database acCurDb = acDoc.Database; PromptSelectionResult selRes; using (EditorUserInteraction preventFlikkering = acDoc.Editor.StartUserInteraction(Autodesk.AutoCAD.ApplicationServices.Core.Application.MainWindow.Handle)) { selRes = acDoc.Editor.GetSelection(); preventFlikkering.End(); } using (Transaction trans = acCurDb.TransactionManager.StartTransaction()) { if (selRes.Status == PromptStatus.OK) { SelectionSet acSet = selRes.Value; if (acSet[0] != null) { if (trans.GetObject(acSet[0].ObjectId, OpenMode.ForRead) is Entity acEnt) { if (acEnt.GetType() == typeof(BlockReference)) { BlockReference selectedBlock = acEnt as BlockReference; LabelBlock.Content = selectedBlock.Name; hBlock = selectedBlock.Handle; AttributeCollection attCol = selectedBlock.AttributeCollection; if (attCol.Count != 0) { List <string> attList = new List <string>(); foreach (ObjectId att in attCol) { using (AttributeReference attRef = trans.GetObject(att, OpenMode.ForRead) as AttributeReference) { attList.Add(attRef.Tag); } } ComboAttribute.ItemsSource = attList; } else { acDoc.Editor.WriteMessage("Selected block did not contain any attributes.\n"); return; } } else { acDoc.Editor.WriteMessage("Selected entity was not a block.\n"); return; } } else { acDoc.Editor.WriteMessage("Selected entity was not an entity.\n"); return; } } else { acDoc.Editor.WriteMessage("Null selection.\n"); return; } } else { acDoc.Editor.WriteMessage("Selection cancelled.\n"); return; } } }
private Entity GetEntityWithAliasAttributes(string alias, Entity toAdd, EntityMetadata metadata, AttributeCollection attributes) { var parentClone = core.GetStronglyTypedEntity(toAdd, metadata, null); foreach (var attr in attributes.Keys) { parentClone.Attributes.Add(alias + "." + attr, new AliasedValue(alias, attr, attributes[attr])); } return(parentClone); }
public IFluentAudit UseFactory <TFactory>() where TFactory : IEntityFactory { AttributeCollection.Add(new MemberInfoAndAttribute(_entityType, new AuditFactoryAttribute(typeof(TFactory)))); return(this); }
public IFluentAudit UseFactory(IEntityFactory factory) { AttributeCollection.Add(new MemberInfoAndAttribute(_entityType, new AuditFactoryAttribute(factory))); return(this); }
protected MethodImpl(LexicalInfo lexicalInfo) : base(lexicalInfo) { _parameters = new ParameterDeclarationCollection(this); _returnTypeAttributes = new AttributeCollection(this); Body = new Block(); }
public void ItemIndexByTypeWithDefaultFieldButNotDefault() { var collection = new AttributeCollection(); Assert.Same(TestAttributeWithDefaultFieldButNotDefault.Default, collection[typeof(TestAttributeWithDefaultFieldButNotDefault)]); }
/// <summary> /// /// </summary> /// <param name="contentTitle"></param> /// <param name="shortDescription"></param> /// <param name="imageUrl"></param> /// <param name="contentType"></param> /// <param name="page"></param> private void AddUpdateMetaTag(string contentTitle, string shortDescription, string imageUrl, string contentType, Page page) { // suppose all meta are not present bool ogTitle = false, ogDescription = false, ogImage = false, TwitterTitle = false, TwitterDescription = false, TwitterImage = false, Title = false, Description = false, Image = false, OGTYPE = false, TWITTERCARD = false, TYPE = false; ControlCollection cntrlColl = page.Header.Controls; int controlsLength = cntrlColl.Count; for (int i = 0; i < controlsLength; i++) { Control controls = cntrlColl[i]; if (controls.GetType() == typeof(HtmlMeta)) { HtmlMeta meta = (HtmlMeta)controls; AttributeCollection attColl = meta.Attributes; string property = string.Empty; if (attColl["property"] != null) { property = attColl["property"].ToString(); } //for Og tag if (!string.IsNullOrEmpty(property)) { switch (property) { case "og:title": meta.Content = contentTitle; ogTitle = true; break; case "og:description": meta.Content = shortDescription; ogDescription = true; break; case "og:image": meta.Content = imageUrl; ogImage = true; break; case "og:type": meta.Content = contentType; OGTYPE = true; break; } } switch (meta.Name) { // for twitter case "twitter:title": meta.Content = contentTitle; TwitterTitle = true; break; case "twitter:description": meta.Content = shortDescription; TwitterDescription = true; break; case "twitter:image": meta.Content = imageUrl; TwitterImage = true; break; //for normal case "title": meta.Content = contentTitle; Title = true; break; case "description": meta.Content = shortDescription; Description = true; break; case "image": meta.Content = imageUrl; Image = true; break; case "twitter:card": meta.Content = contentType; TWITTERCARD = true; break; case "type": meta.Content = contentType; TYPE = true; break; } } } if (!ogTitle) { AppendMeta(id, "OGTITLE", "property", "og:title", contentTitle, cntrlColl); } if (!ogDescription) { AppendMeta(id, "OGDESCRIPTION", "property", "og:description", shortDescription, cntrlColl); } if (!ogImage) { AppendMeta(id, "OGIMAGE", "property", "og:image", imageUrl, cntrlColl); } if (!TwitterTitle) { AppendMeta(id, "TWITTERTITLE", name, "twitter:title", contentTitle, cntrlColl); } if (!TwitterDescription) { AppendMeta(id, "TWITTERDESCRIPTION", name, "twitter:description", shortDescription, cntrlColl); } if (!TwitterImage) { AppendMeta(id, "TWITTERIMAGE", name, "twitter:image", imageUrl, cntrlColl); } if (!Title) { AppendMeta(id, "TITLE", name, "title", contentTitle, cntrlColl); } if (!Description) { AppendMeta(id, "DESCRIPTION", name, "description", shortDescription, cntrlColl); } if (!Image) { AppendMeta(id, "IMAGE", name, "image", imageUrl, cntrlColl); } if (!OGTYPE) { AppendMeta(id, "OGTYPE", "property", "og:type", contentType, cntrlColl); } if (!TWITTERCARD) { AppendMeta(id, "TWITTERCARD", name, "twitter:card", contentType, cntrlColl); } if (!TYPE) { AppendMeta(id, "TYPE", name, "type", contentType, cntrlColl); } page.Title = contentTitle; }
private void BuildAttributes_CustomEventProperty() { var attr = new UICustomEventEditor.DelegateAttribute(MethodDelegate); oCustomAttributes = new AttributeCollection(new Attribute[] { attr }); }
private void BuildAttributes_BrowsableProperty() { var style = new BrowsableTypeConverter.BrowsableLabelStyleAttribute(eBrowsablePropertyLabel); oCustomAttributes = new AttributeCollection(new Attribute[] { style }); }
public void CreateEmptyCollectionWithNull() { AttributeCollection collection = new AttributeCollection(null); Assert.Equal(0, collection.Count); }
protected void GetBidsheetLineItems(Guid bidsheetid) { var fetchData = new { ig1_bidsheet = bidsheetid, ig1_productname = "PM Labor", ig1_categoryname = "Labor", statecode = "0" }; var fetchXml = $@" <fetch> <entity name='ig1_bidsheetpricelistitem'> <attribute name='ig1_materialcost' /> <attribute name='ig1_product' /> <attribute name='ig1_category' /> <filter type='and'> <condition attribute='ig1_bidsheet' operator='eq' value='{fetchData.ig1_bidsheet/*ig1_bidsheet*/}'/> <condition attribute='ig1_productname' operator='neq' value='{fetchData.ig1_productname/*PM Labor*/}'/> <condition attribute='ig1_categoryname' operator='neq' value='{fetchData.ig1_categoryname/*Labor*/}'/> </filter> <link-entity name='product' from='productid' to='ig1_product' link-type='inner'> <attribute name='defaultuomid' alias='uom'/> <filter> <condition attribute='statecode' operator='eq' value='{fetchData.statecode/*0*/}'/> </filter> </link-entity> </entity> </fetch>"; EntityCollection entityCollection = service.RetrieveMultiple(new FetchExpression(fetchXml)); if (entityCollection.Entities.Count > 0) { EntityReference opportunity = null; Entity entity = service.Retrieve("ig1_bidsheet", bidsheetid, new ColumnSet("ig1_opportunitytitle")); if (entity.Attributes.Contains("ig1_opportunitytitle") && entity.Attributes["ig1_opportunitytitle"] != null) { opportunity = (EntityReference)entity.Attributes["ig1_opportunitytitle"]; } decimal totalLaborCost = Convert.ToDecimal(0); Guid[] category = new Guid[entityCollection.Entities.Count]; int i = 0; foreach (var item in entityCollection.Entities) { decimal materialCost = Convert.ToDecimal(0); decimal margin = Convert.ToDecimal(0); decimal totalMaterialCost = Convert.ToDecimal(0); Guid productid = Guid.Empty; Guid categoryid = Guid.Empty; Guid defaultUnit = Guid.Empty; decimal salesCost = Convert.ToDecimal(0); decimal designCost = Convert.ToDecimal(0); decimal travelCost = Convert.ToDecimal(0); decimal laborCost = Convert.ToDecimal(0); decimal categorysdt = Convert.ToDecimal(0); decimal categoryMaterialCost = Convert.ToDecimal(0); decimal productsdt = Convert.ToDecimal(0); AttributeCollection associatedCost = null; var result = item.Attributes; if (result.Contains("ig1_materialcost") && result["ig1_materialcost"] != null) { Money money = (Money)result["ig1_materialcost"]; materialCost = Math.Round(Convert.ToDecimal(money.Value), 2); } if (result.Contains("ig1_product") && result["ig1_product"] != null) { EntityReference entityReference = (EntityReference)result["ig1_product"]; productid = entityReference.Id; } if (result.Contains("ig1_category") && result["ig1_category"] != null) { EntityReference entityReference = (EntityReference)result["ig1_category"]; categoryid = entityReference.Id; associatedCost = IndirectCost(bidsheetid, categoryid); } if (result.Contains("uom") && result["uom"] != null) { AliasedValue aliasedValue = (AliasedValue)result["uom"]; EntityReference entityReference = (EntityReference)aliasedValue.Value; defaultUnit = entityReference.Id; } if (associatedCost != null && associatedCost.Count > 0 && associatedCost.Contains("ig1_materialcost") && associatedCost["ig1_materialcost"] != null) { Money money = (Money)associatedCost["ig1_materialcost"]; categoryMaterialCost = Math.Round(Convert.ToDecimal(money.Value), 2); } if (associatedCost != null && associatedCost.Count > 0 && associatedCost.Contains("ig1_margin") && associatedCost["ig1_margin"] != null) { margin = Math.Round(Convert.ToDecimal(associatedCost["ig1_margin"]), 2); if (margin > 0 && margin < 100) { totalMaterialCost = Math.Round((materialCost / (1 - margin / 100)), 2); } else { totalMaterialCost = materialCost; } } else if (item.Attributes.Contains("ig1_category") && item.Attributes["ig1_category"] != null) { EntityReference entityReference = (EntityReference)item.Attributes["ig1_category"]; if (entityReference.Name == "Contingency") { totalMaterialCost = materialCost; } } if (associatedCost != null && associatedCost.Count > 0 && associatedCost.Contains("ig1_salescost") && associatedCost["ig1_salescost"] != null) { Money money = (Money)associatedCost["ig1_salescost"]; salesCost = Math.Round(Convert.ToDecimal(money.Value), 2); } if (associatedCost != null && associatedCost.Count > 0 && associatedCost.Contains("ig1_designcost") && associatedCost["ig1_designcost"] != null) { Money money = (Money)associatedCost["ig1_designcost"]; designCost = Math.Round(Convert.ToDecimal(money.Value), 2); } if (associatedCost != null && associatedCost.Count > 0 && associatedCost.Contains("ig1_travelcost") && associatedCost["ig1_travelcost"] != null) { Money money = (Money)associatedCost["ig1_travelcost"]; travelCost = Math.Round(Convert.ToDecimal(money.Value), 2); } if (associatedCost != null && associatedCost.Count > 0 && associatedCost.Contains("ig1_pmlaborsme") && associatedCost["ig1_pmlaborsme"] != null && !category.Contains(categoryid)) { laborCost = Math.Round(Convert.ToDecimal(associatedCost["ig1_pmlaborsme"]), 2); totalLaborCost += laborCost; category[i] = categoryid; i++; } categorysdt = salesCost + designCost + travelCost; if (categoryMaterialCost > 0) { productsdt = (materialCost / categoryMaterialCost) * categorysdt; } totalMaterialCost = totalMaterialCost + productsdt; CreatePriceListItem(bidsheetid, productid, defaultUnit, totalMaterialCost); CreateOpportunityLine(productid, opportunity.Id, defaultUnit); } i = 0; Array.Clear(category, i, category.Length); if (totalLaborCost > 0) { Guid defaultUnit = Guid.Empty; Guid productid = Guid.Empty; AttributeCollection result = GetPMLabor(); if (result != null && result.Count > 0 && result.Contains("defaultuomid") && result["defaultuomid"] != null) { EntityReference entityReference = (EntityReference)result["defaultuomid"]; defaultUnit = entityReference.Id; } if (result != null && result.Count > 0 && result.Contains("productid") && result["productid"] != null) { productid = (Guid)result["productid"]; } CreatePriceListItem(bidsheetid, productid, defaultUnit, totalLaborCost); CreateOpportunityLine(productid, opportunity.Id, defaultUnit); } } }
public Button(Bind bind, SecurityDefinition security, string text, Updates updates, AttributeCollection attributes) : base(ControlTypes.Button, bind, security) { this.Text = text; this.Updates = updates; this.Attributes = attributes; }
public static void DisableCustomizeChildControls(AttributeCollection attr) { attr["DesignerDisableCustomizeChildControls"] = "true"; }
public AttributeSection(AttributeTarget attributeTarget, AttributeCollection attributes) { this.attributeTarget = attributeTarget; this.attributes = attributes; }
protected TypeMemberImpl(LexicalInfo lexicalInfo) : base(lexicalInfo) { _attributes = new AttributeCollection(this); }
/// <summary> /// Initializes a new instance of the <see cref="AttributeCollectionAdapter"/> class. /// </summary> /// <param name="collection">The collection.</param> public AttributeCollectionAdapter(AttributeCollection collection) { m_Collection = collection; }
public TypePropertyMetadata(PropertyDescriptor descriptor) { Name = descriptor.Name; Type elementType = TypeUtility.GetElementType(descriptor.PropertyType); IsArray = !elementType.Equals(descriptor.PropertyType); // TODO: What should we do with nullable types here? ClrType = elementType; AttributeCollection propertyAttributes = TypeDescriptorExtensions.ExplicitAttributes(descriptor); // TODO, 336102, ReadOnlyAttribute for editability? RIA used EditableAttribute? ReadOnlyAttribute readonlyAttr = (ReadOnlyAttribute)propertyAttributes[typeof(ReadOnlyAttribute)]; IsReadOnly = (readonlyAttr != null) ? readonlyAttr.IsReadOnly : false; AssociationAttribute associationAttr = (AssociationAttribute)propertyAttributes[typeof(AssociationAttribute)]; if (associationAttr != null) { Association = new TypePropertyAssociationMetadata(associationAttr); } RequiredAttribute requiredAttribute = (RequiredAttribute)propertyAttributes[typeof(RequiredAttribute)]; if (requiredAttribute != null) { _validationRules.Add(new TypePropertyValidationRuleMetadata(requiredAttribute)); } RangeAttribute rangeAttribute = (RangeAttribute)propertyAttributes[typeof(RangeAttribute)]; if (rangeAttribute != null) { Type operandType = rangeAttribute.OperandType; operandType = Nullable.GetUnderlyingType(operandType) ?? operandType; if (operandType.Equals(typeof(Double)) || operandType.Equals(typeof(Int16)) || operandType.Equals(typeof(Int32)) || operandType.Equals(typeof(Int64)) || operandType.Equals(typeof(Single))) { _validationRules.Add(new TypePropertyValidationRuleMetadata(rangeAttribute)); } } StringLengthAttribute stringLengthAttribute = (StringLengthAttribute)propertyAttributes[typeof(StringLengthAttribute)]; if (stringLengthAttribute != null) { _validationRules.Add(new TypePropertyValidationRuleMetadata(stringLengthAttribute)); } DataTypeAttribute dataTypeAttribute = (DataTypeAttribute)propertyAttributes[typeof(DataTypeAttribute)]; if (dataTypeAttribute != null) { if (dataTypeAttribute.DataType.Equals(DataType.EmailAddress) || dataTypeAttribute.DataType.Equals(DataType.Url)) { _validationRules.Add(new TypePropertyValidationRuleMetadata(dataTypeAttribute)); } } }
public static T SetAttributes <T>(this T entity, AttributeCollection attributes, EntityMetadata metadata) where T : Entity { return(SetAttributes(entity, attributes, metadata, null)); }
public void ResetBrowsableAttributes() { browsableAttributes = new AttributeCollection(new Attribute[] { BrowsableAttribute.Yes }); }
/// <summary> /// Clone each record as specified attributes. /// </summary> /// <param name="logicalName"></param> /// <param name="parentRecordIds"></param> /// <param name="attribute"></param> /// <returns>Created Record Ids</returns> public static List <Guid> CloneRecords(string logicalName, Guid[] parentRecordIds, AttributeCollection attribute = null) { /* === ex === * var qe = new QueryExpression("account"){ColumnSet = new ColumnSet(true)}; * var re = CrmSdkLibrary.Connection.OrgService.RetrieveMultiple(qe) ; * AttributeCollection attribute = new AttributeCollection(); * attribute.Add("name", "child Account Test"); * var list = re.Entities.Select(variable => variable.Id).ToList(); * var childAccountIds = CrmSdkLibrary.Copy.CloneRecords(Account.EntityLogicalName,list.ToArray(), attribute); */ var clonedRecordIds = new List <Guid>(); var qe = new QueryExpression(logicalName.ToLower()) { ColumnSet = new ColumnSet(true), Criteria = new FilterExpression() { //Primary Key Cannot Use ContainValues //Conditions = { new ConditionExpression($"{logicalName.ToLower()}id", ConditionOperator.ContainValues, parentRecordIds)} } }; var filter = new FilterExpression(LogicalOperator.Or); foreach (var recordId in parentRecordIds) { filter.AddCondition($"{logicalName.ToLower()}id", ConditionOperator.Equal, recordId); } qe.Criteria.Filters.Add(filter); var retrieve = CrmSdkLibrary.Connection.Service.RetrieveMultiple(qe); foreach (var childRecord in retrieve.Entities) { childRecord.Attributes.Remove(childRecord.LogicalName + "id"); childRecord.Id = Guid.Empty; //^\w+\s?id{1}$ 은 띄어쓰기 포함 var list = (from val in childRecord.Attributes.Where(x => Regex.Match(x.Key, @"^\w+id{1}$").Success) where val.Value.GetType() != typeof(EntityReference) select val.Key).ToList(); foreach (var val in list) { childRecord.Attributes.Remove(val); } if (attribute != null) { foreach (var val in attribute) { childRecord[val.Key] = val.Value; } } //Don't Use Bulk For get Ids clonedRecordIds.Add(CrmSdkLibrary.Connection.Service.Create(childRecord)); } return(clonedRecordIds); }
public void SetUp() { control = new Label(); attributes = new AttributeCollection(new StateBag()); }
/// <summary> /// Adds a way. /// </summary> public override void AddWay(Way way) { if (way == null) { return; } if (way.Nodes == null) { return; } if (way.Nodes.Length == 0) { return; } if (way.Tags == null || way.Tags.Count == 0) { return; } if (_firstPass) { // just keep. if (this.Processors != null) { foreach (var processor in this.Processors) { processor.FirstPass(way); } } if (_vehicleCache.AnyCanTraverse(way.Tags.ToAttributes())) { // way has some use, add all of it's nodes to the index. _nodeIndex.AddId(way.Nodes[0]); for (var i = 0; i < way.Nodes.Length; i++) { _nodeIndex.AddId(way.Nodes[i]); } _nodeIndex.AddId(way.Nodes[way.Nodes.Length - 1]); } } else { if (this.Processors != null) { foreach (var processor in this.Processors) { processor.SecondPass(way); } } var wayAttributes = way.Tags.ToAttributes(); var profileWhiteList = new Whitelist(); if (_vehicleCache.AddToWhiteList(wayAttributes, profileWhiteList)) { // way has some use. // build profile and meta-data. var profileTags = new AttributeCollection(); var metaTags = new AttributeCollection(); foreach (var tag in way.Tags) { if (profileWhiteList.Contains(tag.Key) || _vehicleCache.Vehicles.IsOnProfileWhiteList(tag.Key)) { profileTags.Add(tag); } if (_vehicleCache.Vehicles.IsOnMetaWhiteList(tag.Key)) { metaTags.Add(tag); } } // get profile and meta-data id's. var profileCount = _db.EdgeProfiles.Count; var profile = _db.EdgeProfiles.Add(profileTags); if (profileCount != _db.EdgeProfiles.Count) { var stringBuilder = new StringBuilder(); foreach (var att in profileTags) { stringBuilder.Append(att.Key); stringBuilder.Append('='); stringBuilder.Append(att.Value); stringBuilder.Append(' '); } Itinero.Logging.Logger.Log("RouterDbStreamTarget", Logging.TraceEventType.Information, "Normalized: # profiles {0}: {1}", _db.EdgeProfiles.Count, stringBuilder.ToInvariantString()); } if (profile > Data.Edges.EdgeDataSerializer.MAX_PROFILE_COUNT) { throw new Exception("Maximum supported profiles exeeded, make sure only routing tags are included in the profiles."); } var meta = _db.EdgeMeta.Add(metaTags); // convert way into one or more edges. var node = 0; var isCore = false; while (node < way.Nodes.Length - 1) { // build edge to add. var intermediates = new List <Coordinate>(); var distance = 0.0f; Coordinate coordinate; if (!this.TryGetValue(way.Nodes[node], out coordinate, out isCore)) { // an incomplete way, node not in source. return; } var fromVertex = this.AddCoreNode(way.Nodes[node], coordinate.Latitude, coordinate.Longitude); var fromNode = way.Nodes[node]; var previousCoordinate = coordinate; node++; var toVertex = uint.MaxValue; var toNode = long.MaxValue; while (true) { if (!this.TryGetValue(way.Nodes[node], out coordinate, out isCore)) { // an incomplete way, node not in source. return; } distance += Coordinate.DistanceEstimateInMeter( previousCoordinate, coordinate); if (isCore) { // node is part of the core. toVertex = this.AddCoreNode(way.Nodes[node], coordinate.Latitude, coordinate.Longitude); toNode = way.Nodes[node]; break; } intermediates.Add(coordinate); previousCoordinate = coordinate; node++; } // try to add edge. if (fromVertex == toVertex) { // target and source vertex are identical, this must be a loop. if (intermediates.Count == 1) { // there is just one intermediate, add that one as a vertex. var newCoreVertex = _db.Network.VertexCount; _db.Network.AddVertex(newCoreVertex, intermediates[0].Latitude, intermediates[0].Longitude); this.AddCoreEdge(fromVertex, newCoreVertex, new Data.Network.Edges.EdgeData() { MetaId = meta, Distance = Coordinate.DistanceEstimateInMeter( _db.Network.GetVertex(fromVertex), intermediates[0]), Profile = (ushort)profile }, null); } else if (intermediates.Count >= 2) { // there is more than one intermediate, add two new core vertices. var newCoreVertex1 = _db.Network.VertexCount; _db.Network.AddVertex(newCoreVertex1, intermediates[0].Latitude, intermediates[0].Longitude); var newCoreVertex2 = _db.Network.VertexCount; _db.Network.AddVertex(newCoreVertex2, intermediates[intermediates.Count - 1].Latitude, intermediates[intermediates.Count - 1].Longitude); var distance1 = Coordinate.DistanceEstimateInMeter( _db.Network.GetVertex(fromVertex), intermediates[0]); var distance2 = Coordinate.DistanceEstimateInMeter( _db.Network.GetVertex(toVertex), intermediates[intermediates.Count - 1]); intermediates.RemoveAt(0); intermediates.RemoveAt(intermediates.Count - 1); this.AddCoreEdge(fromVertex, newCoreVertex1, new Data.Network.Edges.EdgeData() { MetaId = meta, Distance = distance1, Profile = (ushort)profile }, null); this.AddCoreEdge(newCoreVertex1, newCoreVertex2, new Data.Network.Edges.EdgeData() { MetaId = meta, Distance = distance - distance2 - distance1, Profile = (ushort)profile }, intermediates); this.AddCoreEdge(newCoreVertex2, toVertex, new Data.Network.Edges.EdgeData() { MetaId = meta, Distance = distance2, Profile = (ushort)profile }, null); } continue; } var edge = _db.Network.GetEdgeEnumerator(fromVertex).FirstOrDefault(x => x.To == toVertex); if (edge == null && fromVertex != toVertex) { // just add edge. this.AddCoreEdge(fromVertex, toVertex, new Data.Network.Edges.EdgeData() { MetaId = meta, Distance = distance, Profile = (ushort)profile }, intermediates); } else { // oeps, already an edge there. if (edge.Data.Distance == distance && edge.Data.Profile == profile && edge.Data.MetaId == meta) { // do nothing, identical duplicate data. } else { // try and use intermediate points if any. // try and use intermediate points. var splitMeta = meta; var splitProfile = profile; var splitDistance = distance; if (intermediates.Count == 0 && edge != null && edge.Shape != null) { // no intermediates in current edge. // save old edge data. intermediates = new List <Coordinate>(edge.Shape); fromVertex = edge.From; toVertex = edge.To; splitMeta = edge.Data.MetaId; splitProfile = edge.Data.Profile; splitDistance = edge.Data.Distance; // just add edge. _db.Network.RemoveEdges(fromVertex, toVertex); // make sure to overwrite and not add an extra edge. this.AddCoreEdge(fromVertex, toVertex, new EdgeData() { MetaId = meta, Distance = System.Math.Max(distance, 0.0f), Profile = (ushort)profile }, null); } if (intermediates.Count > 0) { // intermediates found, use the first intermediate as the core-node. var newCoreVertex = _db.Network.VertexCount; _db.Network.AddVertex(newCoreVertex, intermediates[0].Latitude, intermediates[0].Longitude); // calculate new distance and update old distance. var newDistance = Coordinate.DistanceEstimateInMeter( _db.Network.GetVertex(fromVertex), intermediates[0]); splitDistance -= newDistance; // add first part. this.AddCoreEdge(fromVertex, newCoreVertex, new EdgeData() { MetaId = splitMeta, Distance = System.Math.Max(newDistance, 0.0f), Profile = (ushort)splitProfile }, null); // add second part. intermediates.RemoveAt(0); this.AddCoreEdge(newCoreVertex, toVertex, new EdgeData() { MetaId = splitMeta, Distance = System.Math.Max(splitDistance, 0.0f), Profile = (ushort)splitProfile }, intermediates); } else { // no intermediate or shapepoint found in either one. two identical edge overlayed with different profiles. // add two other vertices with identical positions as the ones given. // connect them with an edge of length '0'. var fromLocation = _db.Network.GetVertex(fromVertex); var newFromVertex = this.AddNewCoreNode(fromNode, fromLocation.Latitude, fromLocation.Longitude); this.AddCoreEdge(fromVertex, newFromVertex, new EdgeData() { Distance = 0, MetaId = splitMeta, Profile = (ushort)splitProfile }, null); var toLocation = _db.Network.GetVertex(toVertex); var newToVertex = this.AddNewCoreNode(toNode, toLocation.Latitude, toLocation.Longitude); this.AddCoreEdge(newToVertex, toVertex, new EdgeData() { Distance = 0, MetaId = splitMeta, Profile = (ushort)splitProfile }, null); this.AddCoreEdge(newFromVertex, newToVertex, new EdgeData() { Distance = splitDistance, MetaId = splitMeta, Profile = (ushort)splitProfile }, null); } } } } } } }
internal Attribute[] GetAttributesFromCollection(AttributeCollection collection) { Attribute[] attributes = new Attribute[collection.Count]; collection.CopyTo(attributes, 0); return(attributes); }
public void bindReturnInfo() { int returnId = this.Page.Request["ReturnId"].ToInt(0); ReturnInfo returnInfo = TradeHelper.GetReturnInfo(returnId); if (returnInfo == null) { this.ShowMsg("退货信息错误!", false); return; } HiddenField hiddenField = this.hidReturnStatus; int num = (int)returnInfo.HandleStatus; hiddenField.Value = num.ToString(); OrderInfo orderInfo = TradeHelper.GetOrderInfo(returnInfo.OrderId); if (orderInfo == null) { this.ShowMsg("错误的订单信息!", false); return; } if (orderInfo.StoreId != this.UserStoreId) { this.ShowMsg("不是门店的订单不能进行处理", false); return; } if (string.IsNullOrEmpty(returnInfo.SkuId)) { this.listPrducts.DataSource = orderInfo.LineItems.Values; } else { Dictionary <string, LineItemInfo> dictionary = new Dictionary <string, LineItemInfo>(); foreach (LineItemInfo value in orderInfo.LineItems.Values) { if (value.SkuId == returnInfo.SkuId) { dictionary.Add(value.SkuId, value); } } this.listPrducts.DataSource = dictionary.Values; } this.listPrducts.DataBind(); this.litOrderId.Text = orderInfo.PayOrderId; this.litOrderTotal.Text = orderInfo.GetTotal(false).F2ToString("f2"); this.litRefundReason.Text = returnInfo.ReturnReason; this.litRefundTotal.Text = returnInfo.RefundAmount.F2ToString("f2"); this.litRemark.Text = returnInfo.UserRemark; Literal literal = this.litReturnQuantity; num = returnInfo.Quantity; literal.Text = num.ToString(); if (returnInfo.RefundType == RefundTypes.InBankCard) { this.litType.Text = EnumDescription.GetEnumDescription((Enum)(object)returnInfo.RefundType, 0) + "(" + returnInfo.BankName + " " + returnInfo.BankAccountName + " " + returnInfo.BankAccountNo + ")"; } else { this.litType.Text = EnumDescription.GetEnumDescription((Enum)(object)returnInfo.RefundType, 0); } string userCredentials = returnInfo.UserCredentials; if (!string.IsNullOrEmpty(userCredentials)) { string[] array = userCredentials.Split('|'); userCredentials = ""; string[] array2 = array; foreach (string str in array2) { userCredentials += string.Format(this.credentialsImgHtml, Globals.GetImageServerUrl() + str); } this.litImageList.Text = userCredentials; } else { this.divCredentials.Visible = false; } if (returnInfo.AfterSaleType == AfterSaleTypes.OnlyRefund) { this.btnAcceptReturn.Text = "确认退款"; this.btnRefuseReturn.Text = "拒绝退款"; this.AfterSaleType = "退款"; } if (returnInfo.HandleStatus == ReturnStatus.Applied && orderInfo.StoreId == this.UserStoreId && (returnInfo.AfterSaleType != AfterSaleTypes.OnlyRefund || (returnInfo.AfterSaleType == AfterSaleTypes.OnlyRefund && orderInfo.IsStoreCollect))) { this.btnAcceptReturn.Visible = true; this.btnRefuseReturn.Visible = true; } if (returnInfo.HandleStatus == ReturnStatus.Deliverying && this.UserStoreId == orderInfo.StoreId && !orderInfo.IsStoreCollect && returnInfo.RefundType != RefundTypes.InBalance) { this.btnGetGoods.Visible = true; } int num2; if ((orderInfo.IsStoreCollect || returnInfo.RefundType == RefundTypes.InBalance) && orderInfo.StoreId == this.UserStoreId) { num2 = ((returnInfo.HandleStatus == ReturnStatus.GetGoods || returnInfo.HandleStatus == ReturnStatus.Deliverying) ? 1 : 0); goto IL_0439; } num2 = 0; goto IL_0439; IL_0439: if (num2 != 0) { if (returnInfo.HandleStatus == ReturnStatus.Deliverying) { this.btnFinishReturn.Text = "确认收货并完成退款"; } this.btnFinishReturn.Visible = true; } if (returnInfo.HandleStatus != ReturnStatus.Refused && returnInfo.HandleStatus != ReturnStatus.Returned) { this.inputPanel.Visible = true; this.showPanel.Visible = false; } else { this.inputPanel.Visible = false; this.showPanel.Visible = true; } if (returnInfo.HandleStatus != 0) { this.txtAdminCellPhone.Visible = false; this.txtAdminShipAddress.Visible = false; this.txtAdminShipTo.Visible = false; this.litAdminCellPhone.Visible = true; this.litAdminShipAddrss.Visible = true; this.litAdminShipTo.Visible = true; this.litAdminCellPhone.Text = returnInfo.AdminCellPhone; this.litAdminShipTo.Text = returnInfo.AdminShipTo; this.litAdminShipAddrss.Text = returnInfo.AdminShipAddress; } else { StoresInfo storeById = StoresHelper.GetStoreById(HiContext.Current.Manager.StoreId); if (storeById != null) { Literal literal2 = this.litAdminShipAddrss; TextBox textBox = this.txtAdminShipAddress; string text3 = literal2.Text = (textBox.Text = RegionHelper.GetFullRegion(storeById.RegionId, " ", true, 0) + " " + storeById.Address); Literal literal3 = this.litAdminShipTo; TextBox textBox2 = this.txtAdminShipTo; text3 = (literal3.Text = (textBox2.Text = storeById.ContactMan)); Literal literal4 = this.litAdminCellPhone; TextBox textBox3 = this.txtAdminCellPhone; text3 = (literal4.Text = (textBox3.Text = storeById.Tel)); } } this.txtAdminRemark.Text = returnInfo.AdminRemark; if (returnInfo.AfterSaleType == AfterSaleTypes.OnlyRefund) { this.txtStatus.Text = EnumDescription.GetEnumDescription((Enum)(object)returnInfo.HandleStatus, 3); } else { this.txtStatus.Text = EnumDescription.GetEnumDescription((Enum)(object)returnInfo.HandleStatus, 0); } this.litRefundMoney.Text = returnInfo.RefundAmount.F2ToString("f2") + "元"; Literal literal5 = this.txtAfterSaleId; num = returnInfo.ReturnId; literal5.Text = num.ToString(); this.txtPayMoney.Text = orderInfo.GetTotal(false).F2ToString("f2"); this.txtRefundMoney.Text = returnInfo.RefundAmount.F2ToString("f2"); HiddenField hiddenField2 = this.hidAfterSaleType; num = (int)returnInfo.AfterSaleType; hiddenField2.Value = num.ToString(); this.hidRefundMaxAmount.Value = orderInfo.GetCanRefundAmount(returnInfo.SkuId, null, 0).F2ToString("f2"); if (returnInfo.AfterSaleType == AfterSaleTypes.ReturnAndRefund && (returnInfo.HandleStatus == ReturnStatus.Deliverying || returnInfo.HandleStatus == ReturnStatus.GetGoods || returnInfo.HandleStatus == ReturnStatus.Returned)) { this.btnViewLogistic.Visible = true; AttributeCollection attributes = this.btnViewLogistic.Attributes; num = returnInfo.ReturnId; attributes.Add("returnsid", num.ToString()); this.btnViewLogistic.Attributes.Add("expresscompanyname", returnInfo.ExpressCompanyName.ToString()); this.btnViewLogistic.Attributes.Add("shipordernumber", returnInfo.ShipOrderNumber.ToString()); } }
protected MethodImpl() { _parameters = new ParameterDeclarationCollection(this); _returnTypeAttributes = new AttributeCollection(this); Body = new Block(); }
private IEnumerable <KeyValuePair <string, string> > HandleBrowse( IRequest request, IHeaders sparams) { var key = Prefix + sparams.HeaderBlock; AttributeCollection rv; if (soapCache.TryGetValue(key, out rv)) { return(rv); } var id = sparams["ObjectID"]; var flag = sparams["BrowseFlag"]; var requested = 20; var provided = 0; var start = 0; try { if (int.TryParse(sparams["RequestedCount"], out requested) && requested <= 0) { requested = 20; } if (int.TryParse(sparams["StartingIndex"], out start) && start <= 0) { start = 0; } } catch (Exception ex) { Debug("Not all params provided", ex); } var root = GetItem(id) as IMediaFolder; if (root == null) { throw new ArgumentException("Invalid id"); } var result = new XmlDocument(); var didl = result.CreateElement(string.Empty, "DIDL-Lite", NS_DIDL); didl.SetAttribute("xmlns:dc", NS_DC); didl.SetAttribute("xmlns:dlna", NS_DLNA); didl.SetAttribute("xmlns:upnp", NS_UPNP); didl.SetAttribute("xmlns:sec", NS_SEC); result.AppendChild(didl); if (flag == "BrowseMetadata") { Browse_AddFolder(result, root); provided++; } else { provided = BrowseFolder_AddItems( request, result, root, start, requested); } var resXML = result.OuterXml; rv = new AttributeCollection { { "Result", resXML }, { "NumberReturned", provided.ToString() }, { "TotalMatches", root.ChildCount.ToString() }, { "UpdateID", systemID.ToString() } }; soapCache[key] = rv; return(rv); }