private static void SetAnnotation(IEnumerable<IEdmDirectValueAnnotation> immutableAnnotations, ref object transientAnnotations, string namespaceName, string localName, object value) { IEdmDirectValueAnnotation edmDirectValueAnnotation; Func<IEdmDirectValueAnnotation, bool> func = null; bool flag = false; if (immutableAnnotations != null) { IEnumerable<IEdmDirectValueAnnotation> edmDirectValueAnnotations = immutableAnnotations; if (func == null) { func = (IEdmDirectValueAnnotation existingAnnotation) => { if (existingAnnotation.NamespaceUri != namespaceName) { return false; } else { return existingAnnotation.Name == localName; } } ; } if (edmDirectValueAnnotations.Any<IEdmDirectValueAnnotation>(func)) { flag = true; } } if (value != null || flag) { if (!(namespaceName == "http://schemas.microsoft.com/ado/2011/04/edm/documentation") || value == null || value as IEdmDocumentation != null) { if (value != null) { edmDirectValueAnnotation = new EdmDirectValueAnnotation(namespaceName, localName, value); } else { edmDirectValueAnnotation = new EdmDirectValueAnnotation(namespaceName, localName); } IEdmDirectValueAnnotation edmDirectValueAnnotation1 = edmDirectValueAnnotation; if (transientAnnotations != null) { IEdmDirectValueAnnotation edmDirectValueAnnotation2 = transientAnnotations as IEdmDirectValueAnnotation; if (edmDirectValueAnnotation2 == null) { VersioningList<IEdmDirectValueAnnotation> edmDirectValueAnnotations1 = (VersioningList<IEdmDirectValueAnnotation>)transientAnnotations; int num = 0; while (num < edmDirectValueAnnotations1.Count) { IEdmDirectValueAnnotation item = edmDirectValueAnnotations1[num]; if (!(item.NamespaceUri == namespaceName) || !(item.Name == localName)) { num++; } else { edmDirectValueAnnotations1 = edmDirectValueAnnotations1.RemoveAt(num); break; } } transientAnnotations = edmDirectValueAnnotations1.Add(edmDirectValueAnnotation1); return; } else { if (!(edmDirectValueAnnotation2.NamespaceUri == namespaceName) || !(edmDirectValueAnnotation2.Name == localName)) { transientAnnotations = VersioningList<IEdmDirectValueAnnotation>.Create().Add(edmDirectValueAnnotation2).Add(edmDirectValueAnnotation1); return; } else { transientAnnotations = edmDirectValueAnnotation1; return; } } } else { transientAnnotations = edmDirectValueAnnotation1; return; } } else { throw new InvalidOperationException(Strings.Annotations_DocumentationPun(value.GetType().Name)); } } else { EdmDirectValueAnnotationsManager.RemoveTransientAnnotation(ref transientAnnotations, namespaceName, localName); return; } }
private static void SetAnnotation(IEnumerable <IEdmDirectValueAnnotation> immutableAnnotations, ref object transientAnnotations, string namespaceName, string localName, object value) { IEdmDirectValueAnnotation edmDirectValueAnnotation; Func <IEdmDirectValueAnnotation, bool> func = null; bool flag = false; if (immutableAnnotations != null) { IEnumerable <IEdmDirectValueAnnotation> edmDirectValueAnnotations = immutableAnnotations; if (func == null) { func = (IEdmDirectValueAnnotation existingAnnotation) => { if (existingAnnotation.NamespaceUri != namespaceName) { return(false); } else { return(existingAnnotation.Name == localName); } } ; } if (edmDirectValueAnnotations.Any <IEdmDirectValueAnnotation>(func)) { flag = true; } } if (value != null || flag) { if (!(namespaceName == "http://schemas.microsoft.com/ado/2011/04/edm/documentation") || value == null || value as IEdmDocumentation != null) { if (value != null) { edmDirectValueAnnotation = new EdmDirectValueAnnotation(namespaceName, localName, value); } else { edmDirectValueAnnotation = new EdmDirectValueAnnotation(namespaceName, localName); } IEdmDirectValueAnnotation edmDirectValueAnnotation1 = edmDirectValueAnnotation; if (transientAnnotations != null) { IEdmDirectValueAnnotation edmDirectValueAnnotation2 = transientAnnotations as IEdmDirectValueAnnotation; if (edmDirectValueAnnotation2 == null) { VersioningList <IEdmDirectValueAnnotation> edmDirectValueAnnotations1 = (VersioningList <IEdmDirectValueAnnotation>)transientAnnotations; int num = 0; while (num < edmDirectValueAnnotations1.Count) { IEdmDirectValueAnnotation item = edmDirectValueAnnotations1[num]; if (!(item.NamespaceUri == namespaceName) || !(item.Name == localName)) { num++; } else { edmDirectValueAnnotations1 = edmDirectValueAnnotations1.RemoveAt(num); break; } } transientAnnotations = edmDirectValueAnnotations1.Add(edmDirectValueAnnotation1); return; } else { if (!(edmDirectValueAnnotation2.NamespaceUri == namespaceName) || !(edmDirectValueAnnotation2.Name == localName)) { transientAnnotations = VersioningList <IEdmDirectValueAnnotation> .Create().Add(edmDirectValueAnnotation2).Add(edmDirectValueAnnotation1); return; } else { transientAnnotations = edmDirectValueAnnotation1; return; } } } else { transientAnnotations = edmDirectValueAnnotation1; return; } } else { throw new InvalidOperationException(Strings.Annotations_DocumentationPun(value.GetType().Name)); } } else { EdmDirectValueAnnotationsManager.RemoveTransientAnnotation(ref transientAnnotations, namespaceName, localName); return; } }