private static InformationSource GetMissingRootAsNewSource(ContentItem root, string masterLocation, out bool foundExistingSource) { InformationSource source = root.Source ?? InformationSource.CreateDefault(); IInformationObject informationObject = (IInformationObject)root.RootObject; if (informationObject == null) { foundExistingSource = false; return(null); } string sourceContentLocation = informationObject.GetLocationRelativeToContentRoot(masterLocation, root.RootName); CloudBlob blob; IInformationObject existingObject = StorageSupport.RetrieveInformationWithBlob(sourceContentLocation, root.RootType, out blob); if (existingObject == null) { informationObject.SetLocationRelativeToContentRoot(masterLocation, root.RootName); blob = StorageSupport.StoreInformation(informationObject); foundExistingSource = false; } else { informationObject = existingObject; root.RootObject = existingObject; foundExistingSource = true; } source.SetBlobValuesToSource(blob); source.SetInformationObjectValuesToSource(root.RootName, informationObject.GetType().FullName); source.IsDynamic = root.IsDynamicRoot; return(source); }
private static string GetDefaultDynamicRenderingViewURL(IInformationObject informationObject) { string viewName = informationObject.GetType().FullName + "_DefaultView.phtml"; string viewItemLocation = informationObject.RelativeLocation; string viewItemURL = RenderWebSupport.GetUrlFromRelativeLocation(viewItemLocation); return(viewName + "?viewItem=" + HttpUtility.UrlEncode(viewItemURL)); }
public static void SetCollectionSubscriptionToMaster(IInformationObject containerObject, string masterCollectionLocation, Type collectionType) { AddSubscriptionToObject(masterCollectionLocation, containerObject.RelativeLocation, SubscribeType_MasterCollectionToContainerUpdate, collectionType.FullName, containerObject.GetType().FullName); }
public static void SetReferenceSubscriptionToMaster(IInformationObject containerObject, IInformationObject referenceInstance, IInformationObject masterInstance) { AddSubscriptionToObject(masterInstance.RelativeLocation, containerObject.RelativeLocation, SubscribeType_MasterToReferenceUpdate, targetTypeName: masterInstance.GetType().FullName, subscriberTypeName: containerObject.GetType().FullName); }
void IInformationObject.UpdateMasterValueTreeFromOtherInstance(IInformationObject sourceMaster) { if (sourceMaster == null) throw new ArgumentNullException("sourceMaster"); if (GetType() != sourceMaster.GetType()) throw new InvalidDataException("Type mismatch in UpdateMasterValueTree"); IInformationObject iObject = this; if(iObject.IsIndependentMaster == false) throw new InvalidDataException("UpdateMasterValueTree called on non-master type"); if(ID != sourceMaster.ID) throw new InvalidDataException("UpdateMasterValueTree is supported only on masters with same ID"); CopyContentFrom((NetworkUsageCollection) sourceMaster); }
private static byte[] SerializeInformationObjectToBuffer(IInformationObject informationObject) { Type informationObjectType = informationObject.GetType(); using (MemoryStream memoryStream = new MemoryStream()) { byte[] dataContent = null; StorageSerializationType storageSerializationType = getStorageSerializationType(informationObjectType); if (storageSerializationType == StorageSerializationType.XML) { DataContractSerializer ser = new DataContractSerializer(informationObjectType); using ( XmlTextWriter writer = new XmlTextWriter(memoryStream, Encoding.UTF8) { Formatting = Formatting.Indented }) { ser.WriteObject(writer, informationObject); writer.Flush(); dataContent = memoryStream.ToArray(); } } else if (storageSerializationType == StorageSerializationType.JSON) { DataContractJsonSerializer serializer = new DataContractJsonSerializer(informationObjectType); serializer.WriteObject(memoryStream, informationObject); dataContent = memoryStream.ToArray(); } else if (storageSerializationType == StorageSerializationType.Binary) { BinaryFormatter binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(memoryStream, informationObject); dataContent = memoryStream.ToArray(); } else // if (storageSerializationType == StorageSerializationType.Custom) { throw new NotSupportedException("Custom or unspecified formatting not supported"); } return dataContent; } }
public static string GetDefaultStaticViewName(IInformationObject informationObject) { string viewName = informationObject.GetType().FullName + "_" + informationObject.ID + "_DefaultView.phtml"; return viewName; }
public static string GetDefaultStaticTemplateName(IInformationObject informationObject) { string templateName = informationObject.GetType().FullName + "_DefaultView.phtml"; return templateName; }
private static string GetDefaultDynamicRenderingViewURL(IInformationObject informationObject) { string viewName = informationObject.GetType().FullName + "_DefaultView.phtml"; string viewItemLocation = informationObject.RelativeLocation; string viewItemURL = RenderWebSupport.GetUrlFromRelativeLocation(viewItemLocation); return viewName + "?viewItem=" + HttpUtility.UrlEncode(viewItemURL); }
public static void SetReferenceSubscriptionToMaster(IInformationObject containerObject, IInformationObject referenceInstance, IInformationObject masterInstance) { AddSubscriptionToObject(masterInstance.RelativeLocation, containerObject.RelativeLocation, SubscribeType_MasterToReferenceUpdate, targetTypeName:masterInstance.GetType().FullName, subscriberTypeName:containerObject.GetType().FullName); }
public static string GetDefaultStaticViewName(IInformationObject informationObject) { string viewName = informationObject.GetType().FullName + "_" + informationObject.ID + "_DefaultView.phtml"; return(viewName); }
public static string GetDefaultStaticTemplateName(IInformationObject informationObject) { string templateName = informationObject.GetType().FullName + "_DefaultView.phtml"; return(templateName); }
public SemanticInformationItem(IInformationObject informationObject) { ItemFullType = informationObject.GetType().FullName; ItemValue = informationObject.RelativeLocation; }
public static void InitializeChainAndReturnPropertyOwningObject(IInformationObject createdObject, string objectProp, out object actualContainingObject, out string fieldPropertyName) { actualContainingObject = null; fieldPropertyName = null; if (objectProp.Contains("___") == false) return; string[] objectChain = objectProp.Split(new[] { "___" }, StringSplitOptions.None); fieldPropertyName = objectChain[objectChain.Length - 1]; Stack<string> objectChainStack = new Stack<string>(objectChain.Reverse().Skip(1)); actualContainingObject = createdObject; while (objectChainStack.Count > 0) { Type currType = actualContainingObject.GetType(); string currObjectProp = objectChainStack.Pop(); PropertyInfo prop = currType.GetProperty(currObjectProp); if (prop == null) throw new InvalidDataException("Property not found by name: " + currObjectProp); var currPropValue = prop.GetValue(actualContainingObject, null); if (currPropValue == null) { var currPropType = prop.PropertyType; currPropValue = Activator.CreateInstance(currPropType); prop.SetValue(actualContainingObject, currPropValue, null); } actualContainingObject = currPropValue; } }