/// <summary>
        /// Writes a service document in ATOM/XML format.
        /// </summary>
        /// <param name="defaultWorkspace">The default workspace to write in the service document.</param>
        internal void WriteServiceDocument(ODataWorkspace defaultWorkspace)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(defaultWorkspace != null, "defaultWorkspace != null");

            IEnumerable <ODataResourceCollectionInfo> collections = defaultWorkspace.Collections;

            this.WritePayloadStart();

            // <app:service>
            this.XmlWriter.WriteStartElement(string.Empty, AtomConstants.AtomPublishingServiceElementName, AtomConstants.AtomPublishingNamespace);

            // xml:base=...
            if (this.MessageWriterSettings.BaseUri != null)
            {
                this.XmlWriter.WriteAttributeString(AtomConstants.XmlBaseAttributeName, AtomConstants.XmlNamespace, this.MessageWriterSettings.BaseUri.AbsoluteUri);
            }

            // xmlns=http://www.w3.org/2007/app
            this.XmlWriter.WriteAttributeString(AtomConstants.XmlnsNamespacePrefix, AtomConstants.XmlNamespacesNamespace, AtomConstants.AtomPublishingNamespace);

            // xmlns:atom="http://www.w3.org/2005/Atom"
            this.XmlWriter.WriteAttributeString(
                AtomConstants.NonEmptyAtomNamespacePrefix,
                AtomConstants.XmlNamespacesNamespace,
                AtomConstants.AtomNamespace);

            // <app:workspace>
            this.XmlWriter.WriteStartElement(string.Empty, AtomConstants.AtomPublishingWorkspaceElementName, AtomConstants.AtomPublishingNamespace);

            this.atomServiceDocumentMetadataSerializer.WriteWorkspaceMetadata(defaultWorkspace);

            if (collections != null)
            {
                foreach (ODataResourceCollectionInfo collectionInfo in collections)
                {
                    // validate that the collection has a non-null url.
                    ValidationUtils.ValidateResourceCollectionInfo(collectionInfo);

                    // <app:collection>
                    this.XmlWriter.WriteStartElement(string.Empty, AtomConstants.AtomPublishingCollectionElementName, AtomConstants.AtomPublishingNamespace);

                    // The name of the collection is the entity set name; The href of the <app:collection> element must be the link for the entity set.
                    // Since we model the collection as having a 'Name' (for JSON) we require a base Uri for Atom/Xml.
                    this.XmlWriter.WriteAttributeString(AtomConstants.AtomHRefAttributeName, this.UriToUrlAttributeValue(collectionInfo.Url));

                    this.atomServiceDocumentMetadataSerializer.WriteResourceCollectionMetadata(collectionInfo);

                    // </app:collection>
                    this.XmlWriter.WriteEndElement();
                }
            }

            // </app:workspace>
            this.XmlWriter.WriteEndElement();

            // </app:service>
            this.XmlWriter.WriteEndElement();

            this.WritePayloadEnd();
        }
Пример #2
0
 /// <summary>
 /// Creates the metadata URI for a collection of entity reference links.
 /// </summary>
 /// <param name="serializationInfo">Serialization information to generate the metadata uri.</param>
 /// <param name="entitySet">The entity set of the declaring type of the navigation property</param>
 /// <param name="navigationProperty">The navigation property to create the metadata URI for.</param>
 /// <param name="metadataUri">Returns the metadata URI for an entity reference link or a collection of entity reference links.</param>
 /// <returns>true if we have successfully built the metadata URI; false otherwise.</returns>
 internal override bool TryBuildEntityReferenceLinksMetadataUri(ODataEntityReferenceLinksSerializationInfo serializationInfo, IEdmEntitySet entitySet, IEdmNavigationProperty navigationProperty, out Uri metadataUri)
 {
     DebugUtils.CheckNoExternalCallers();
     metadataUri = null;
     return(false);
 }
Пример #3
0
 /// <summary>
 /// Creates the metadata URI for the service document.
 /// </summary>
 /// <param name="metadataUri">Returns the metadata URI for the service document.</param>
 /// <returns>true if we have successfully built the metadata URI; false otherwise.</returns>
 internal override bool TryBuildServiceDocumentMetadataUri(out Uri metadataUri)
 {
     DebugUtils.CheckNoExternalCallers();
     metadataUri = null;
     return(false);
 }
Пример #4
0
 /// <summary>
 /// Creates the metadata URI for a type.
 /// </summary>
 /// <param name="metadataDocumentUri">The non-null, absolute metadata document URI.</param>
 /// <param name="fullTypeName">The fully qualified type name to create the metadata URI for.</param>
 /// <returns>Returns the metadata URI for a value based on its type.</returns>
 private static Uri CreateTypeMetadataUri(ODataMetadataDocumentUri metadataDocumentUri, string fullTypeName)
 {
     DebugUtils.CheckNoExternalCallers();
     return(fullTypeName == null ? null : new Uri(metadataDocumentUri.BaseUri, JsonLightConstants.MetadataUriFragmentIndicator + fullTypeName));
 }
Пример #5
0
 /// <summary>
 /// Creates the metadata URI for an entry based on the entity set it belongs to.
 /// </summary>
 /// <param name="typeContext">The context object to answer basic questions regarding the type of the entry.</param>
 /// <param name="metadataUri">Returns the metadata URI for an entry based on the entity set it belongs to.</param>
 /// <returns>true if we have successfully built the metadata URI; false otherwise.</returns>
 internal override bool TryBuildEntryMetadataUri(ODataFeedAndEntryTypeContext typeContext, out Uri metadataUri)
 {
     DebugUtils.CheckNoExternalCallers();
     metadataUri = null;
     return(false);
 }
Пример #6
0
 static void PrintPlayerInfo()
 {
     ConsoleModule.WriteLine(DebugUtils.JsonStringify(GameState.Instance.PlayerRpgState));
 }
Пример #7
0
 /// <summary>
 /// Creates the metadata URI for an entry based on the entity set it belongs to.
 /// </summary>
 /// <param name="typeContext">The context object to answer basic questions regarding the type of the entry.</param>
 /// <param name="metadataUri">Returns the metadata URI for an entry based on the entity set it belongs to.</param>
 /// <returns>true if we have successfully built the metadata URI; false otherwise.</returns>
 internal override bool TryBuildEntryMetadataUri(ODataFeedAndEntryTypeContext typeContext, out Uri metadataUri)
 {
     DebugUtils.CheckNoExternalCallers();
     metadataUri = CreateFeedOrEntryMetadataUri(this.metadataDocumentUri, this.model, typeContext, /*isEntry*/ true, this.writingResponse);
     return(metadataUri != null);
 }
Пример #8
0
 internal static ODataException CreateException(string exceptionMessage)
 {
     DebugUtils.CheckNoExternalCallers();
     return(new ODataException(exceptionMessage));
 }
Пример #9
0
 private void DropDown_eventSelectedIndexChanged(UIComponent component, int index)
 {
     DebugUtils.Log("UINetTypeItem.DropDown_eventChanged");
     OnChangedCallback?.Invoke();
 }
Пример #10
0
        public static void GenerateModel(IBase baseObject, string modelsFolderPath, string modelName, IGeneratorConfiguration generatorConfiguration, List <Generators.EntityProperty> entityProperties)
        {
            var host             = new TemplateEngineHost();
            var pass             = generatorConfiguration.CurrentPass;
            var exports          = new List <ESModule>();
            var declarations     = new List <IDeclarable>();
            var isIdentityEntity = generatorConfiguration.IsIdentityEntity(baseObject);
            var root             = baseObject.Root;
            var isGeneratedModel = false;
            Dictionary <string, object> sessionVariables;
            FileInfo fileInfo;
            string   fileLocation;
            string   filePath;
            string   output;

            try
            {
                // WebAPIModelGenerator class

                if (root is IRootWithOptions)
                {
                    var rootWithOptions = (IRootWithOptions)root;

                    isGeneratedModel = rootWithOptions.IsGeneratedModel;
                }

                sessionVariables = new Dictionary <string, object>();

                sessionVariables.Add("EntityProperties", entityProperties);
                sessionVariables.Add("ModelName", modelName);
                sessionVariables.Add("IsGeneratedModel", isGeneratedModel);
                sessionVariables.Add("EntityName", baseObject.Name);

                if (baseObject is IEntityWithPrefix)
                {
                    var entityWithPathPrefix = baseObject.CastTo <IEntityWithPrefix>();

                    fileLocation = PathCombine(modelsFolderPath, entityWithPathPrefix.PathPrefix);

                    sessionVariables.Add("RootNamespace", entityWithPathPrefix.Namespace);
                    sessionVariables.Add("NamespaceSuffix", entityWithPathPrefix.PathPrefix);
                }
                else
                {
                    fileLocation = modelsFolderPath;
                    sessionVariables.Add("RootNamespace", generatorConfiguration.AppName);
                }

                filePath = PathCombine(fileLocation, modelName + ".cs");
                fileInfo = new FileInfo(filePath);

                if (isIdentityEntity)
                {
                    output = host.Generate <WebAPIIdentityModelClassTemplate>(sessionVariables, false);
                }
                else
                {
                    output = host.Generate <WebAPIModelClassTemplate>(sessionVariables, false);
                }

                if (generatorConfiguration.FileSystem.Contains(fileInfo.FullName))
                {
                    if (pass != GeneratorPass.HierarchyOnly)
                    {
                        var file = (AbstraX.FolderStructure.File)generatorConfiguration.FileSystem[fileInfo.FullName];

                        if (file.Hash != 0 && file.Hash != output.GetHashCode())
                        {
                            DebugUtils.Break();
                        }

                        generatorConfiguration.CreateFile(fileInfo, output, FileKind.Services, () => generatorConfiguration.GenerateInfo(sessionVariables, "WebAPIModel Class"));
                    }
                }
                else
                {
                    generatorConfiguration.CreateFile(fileInfo, output, FileKind.Services, () => generatorConfiguration.GenerateInfo(sessionVariables, "WebAPIModel Class"));
                }
            }
            catch (Exception e)
            {
                generatorConfiguration.AppGeneratorEngine.WriteError(e.ToString());
            }
        }
Пример #11
0
 /// <summary>
 /// Skips over a JSON value (primitive, object or array).
 /// </summary>
 /// <param name="jsonReader">The <see cref="JsonReader"/> to read from.</param>
 /// <remarks>
 /// Pre-Condition: JsonNodeType.PrimitiveValue, JsonNodeType.StartArray or JsonNodeType.StartObject
 /// Post-Condition: JsonNodeType.PrimitiveValue, JsonNodeType.EndArray or JsonNodeType.EndObject
 /// </remarks>
 internal static void SkipValue(this JsonReader jsonReader)
 {
     DebugUtils.CheckNoExternalCallers();
     SkipValue(jsonReader, null);
 }
Пример #12
0
 /// <summary>
 /// Creates a new instance of <see cref="SegmentKeySerializer"/>.
 /// </summary>
 internal SegmentKeySerializer()
 {
     DebugUtils.CheckNoExternalCallers();
 }
Пример #13
0
 /// <summary>
 /// Creates a new instance of <see cref="DefaultKeySerializer"/>.
 /// </summary>
 internal DefaultKeySerializer()
 {
     DebugUtils.CheckNoExternalCallers();
 }
Пример #14
0
 private void SetupRoot()
 {
     this.m_PlantRoot = base.transform.FindDeepChild("PlantRoot");
     DebugUtils.Assert(this.m_PlantRoot, true);
 }
Пример #15
0
 protected virtual void SetupMouth()
 {
     this.m_Mouth = base.transform.FindDeepChild("Mouth").gameObject;
     DebugUtils.Assert(this.m_Mouth, true);
     this.m_MouthShift = Vector3.Distance(base.transform.position, this.m_Mouth.transform.position);
 }
Пример #16
0
 private void DeleteButton_eventClicked(UIComponent component, UIMouseEventParameter eventParam)
 {
     DebugUtils.Log("UINetTypeItem.DeleteButton_eventClicked");
     OnDeleteCallback?.Invoke();
 }
Пример #17
0
 static void PrintInventoryModel(string model)
 {
     ConsoleModule.WriteLine(DebugUtils.JsonStringify(InventoryModel.GetModel(model)));
 }
Пример #18
0
        public static void DumpGameState()
        {
            var gs = DebugUtils.JsonStringify(GameState.Instance, true);

            Debug.Log(gs);
        }
Пример #19
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="jsonLightInputContext">The JsonLight input context to read from.</param>
 internal ODataJsonLightPayloadKindDetectionDeserializer(ODataJsonLightInputContext jsonLightInputContext)
     : base(jsonLightInputContext)
 {
     DebugUtils.CheckNoExternalCallers();
 }
Пример #20
0
        public static void DumpMetaState()
        {
            var ms = DebugUtils.JsonStringify(MetaState.Instance, true);

            Debug.Log(ms);
        }
Пример #21
0
 /// <summary>
 /// Creates the metadata URI for the service document.
 /// </summary>
 /// <param name="metadataUri">Returns the metadata URI for the service document.</param>
 /// <returns>true if we have successfully built the metadata URI; false otherwise.</returns>
 internal override bool TryBuildServiceDocumentMetadataUri(out Uri metadataUri)
 {
     DebugUtils.CheckNoExternalCallers();
     metadataUri = this.metadataDocumentUri.BaseUri;
     return(true);
 }
Пример #22
0
        public static void DumpPersistState()
        {
            var ps = DebugUtils.JsonStringify(PersistState.Instance, true);

            Debug.Log(ps);
        }
Пример #23
0
 /// <summary>
 /// Prevents a default instance of the <see cref="NullMetadataUriBuilder"/> class from being created.
 /// </summary>
 private NullMetadataUriBuilder()
 {
     DebugUtils.CheckNoExternalCallers();
 }
Пример #24
0
        /// <summary>
        /// Writes the metadata properties for an entry which can occur both at the start or at the end.
        /// </summary>
        /// <param name="entryState">The entry state for which to write the metadata properties.</param>
        /// <remarks>
        /// This method will only write properties which were not written yet.
        /// </remarks>
        internal void WriteEntryMetadataProperties(IODataJsonLightWriterEntryState entryState)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(entryState != null, "entryState != null");

            ODataEntry entry = entryState.Entry;

            // Write the "odata.editLink": "edit-link-uri"
            Uri editLinkUriValue = entry.EditLink;

            if (editLinkUriValue != null && !entryState.EditLinkWritten)
            {
                this.JsonWriter.WriteName(ODataAnnotationNames.ODataEditLink);
                this.JsonWriter.WriteValue(this.UriToString(editLinkUriValue));
                entryState.EditLinkWritten = true;
            }

            // Write the "odata.readLink": "read-link-uri"
            Uri readLinkUriValue = entry.ReadLink;

            if (readLinkUriValue != null && !entryState.ReadLinkWritten)
            {
                this.JsonWriter.WriteName(ODataAnnotationNames.ODataReadLink);
                this.JsonWriter.WriteValue(this.UriToString(readLinkUriValue));
                entryState.ReadLinkWritten = true;
            }

            // Write MLE metadata
            ODataStreamReferenceValue mediaResource = entry.MediaResource;

            if (mediaResource != null)
            {
                // Write the "odata.mediaEditLink": "edit-link-uri"
                Uri mediaEditLinkUriValue = mediaResource.EditLink;
                if (mediaEditLinkUriValue != null && !entryState.MediaEditLinkWritten)
                {
                    this.JsonWriter.WriteName(ODataAnnotationNames.ODataMediaEditLink);
                    this.JsonWriter.WriteValue(this.UriToString(mediaEditLinkUriValue));
                    entryState.MediaEditLinkWritten = true;
                }

                // Write the "odata.mediaReadLink": "read-link-uri"
                Uri mediaReadLinkUriValue = mediaResource.ReadLink;
                if (mediaReadLinkUriValue != null && !entryState.MediaReadLinkWritten)
                {
                    this.JsonWriter.WriteName(ODataAnnotationNames.ODataMediaReadLink);
                    this.JsonWriter.WriteValue(this.UriToString(mediaReadLinkUriValue));
                    entryState.MediaReadLinkWritten = true;
                }

                // Write the "odata.mediaContentType": "content/type"
                string mediaContentType = mediaResource.ContentType;
                if (mediaContentType != null && !entryState.MediaContentTypeWritten)
                {
                    this.JsonWriter.WriteName(ODataAnnotationNames.ODataMediaContentType);
                    this.JsonWriter.WriteValue(mediaContentType);
                    entryState.MediaContentTypeWritten = true;
                }

                // Write the "odata.mediaETag": "ETAG"
                string mediaETag = mediaResource.ETag;
                if (mediaETag != null && !entryState.MediaETagWritten)
                {
                    this.JsonWriter.WriteName(ODataAnnotationNames.ODataMediaETag);
                    this.JsonWriter.WriteValue(mediaETag);
                    entryState.MediaETagWritten = true;
                }
            }

            // TODO: actions
            // TODO: functions
            // TODO: association links
        }
Пример #25
0
 /// <summary>
 /// Creates the metadata URI for a property based on its value.
 /// </summary>
 /// <param name="property">The property to create the metadata URI for.</param>
 /// <param name="metadataUri">Returns the metadata URI for a property based on its owning type.</param>
 /// <returns>true if we have successfully built the metadata URI; false otherwise.</returns>
 internal override bool TryBuildMetadataUriForValue(ODataProperty property, out Uri metadataUri)
 {
     DebugUtils.CheckNoExternalCallers();
     metadataUri = null;
     return(false);
 }
Пример #26
0
        /// <summary>
        /// Writes an annotation group declaration or annotation group reference if specified for the entry.
        /// </summary>
        /// <param name="entry">The entry to write the annotation group declaration or reference for.</param>
        internal void WriteAnnotationGroup(ODataEntry entry)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(entry != null, "entry != null");

            ODataJsonLightAnnotationGroup annotationGroup = entry.GetAnnotation <ODataJsonLightAnnotationGroup>();

            if (annotationGroup == null)
            {
                return;
            }

            if (!this.JsonLightOutputContext.WritingResponse)
            {
                throw new ODataException(OData.Strings.ODataJsonLightEntryAndFeedSerializer_AnnotationGroupInRequest);
            }

            string annotationGroupName = annotationGroup.Name;

            if (string.IsNullOrEmpty(annotationGroupName))
            {
                throw new ODataException(OData.Strings.ODataJsonLightEntryAndFeedSerializer_AnnotationGroupWithoutName);
            }

            // Check whether this is the first occurrence of the annotation group.
            ODataJsonLightAnnotationGroup existingAnnotationGroup;

            if (this.annotationGroups.TryGetValue(annotationGroupName, out existingAnnotationGroup))
            {
                // Make sure the annotation groups are reference equal if they have the same name.
                if (!object.ReferenceEquals(existingAnnotationGroup, annotationGroup))
                {
                    throw new ODataException(OData.Strings.ODataJsonLightEntryAndFeedSerializer_DuplicateAnnotationGroup(annotationGroupName));
                }

                // Write an annotation group reference
                this.JsonWriter.WriteName(ODataAnnotationNames.ODataAnnotationGroupReference);
                this.JsonWriter.WritePrimitiveValue(annotationGroupName, this.JsonLightOutputContext.Version);
            }
            else
            {
                // Write an annotation group declaration
                this.JsonWriter.WriteName(ODataAnnotationNames.ODataAnnotationGroup);
                this.JsonWriter.StartObjectScope();
                this.JsonWriter.WriteName(JsonLightConstants.ODataAnnotationGroupNamePropertyName);
                this.JsonWriter.WritePrimitiveValue(annotationGroupName, this.JsonLightOutputContext.Version);

                if (annotationGroup.Annotations != null)
                {
                    foreach (KeyValuePair <string, object> kvp in annotationGroup.Annotations)
                    {
                        string annotationKey = kvp.Key;
                        Debug.Assert(annotationKey != null, "annotationKey != null");
                        if (annotationKey.Length == 0)
                        {
                            throw new ODataException(OData.Strings.ODataJsonLightEntryAndFeedSerializer_AnnotationGroupMemberWithoutName(annotationGroup.Name));
                        }

                        if (!ODataJsonLightReaderUtils.IsAnnotationProperty(annotationKey))
                        {
                            throw new ODataException(OData.Strings.ODataJsonLightEntryAndFeedSerializer_AnnotationGroupMemberMustBeAnnotation(annotationKey, annotationGroup.Name));
                        }

                        this.JsonWriter.WriteName(annotationKey);

                        object annotationValue       = kvp.Value;
                        string annotationValueString = annotationValue as string;
                        if (annotationValueString == null && annotationValue != null)
                        {
                            throw new ODataException(OData.Strings.ODataJsonLightEntryAndFeedSerializer_AnnotationGroupMemberWithInvalidValue(annotationKey, annotationGroup.Name, annotationValue.GetType().FullName));
                        }

                        this.JsonWriter.WritePrimitiveValue(annotationValueString, this.JsonLightOutputContext.Version);
                    }
                }

                this.JsonWriter.EndObjectScope();

                // Remember that we wrote the declaration of the annotation group.
                this.annotationGroups.Add(annotationGroupName, annotationGroup);
            }
        }
Пример #27
0
 /// <summary>
 /// Creates the metadata URI for an operation (function, action, service op) based on its function import.
 /// </summary>
 /// <param name="serializationInfo">Serialization information to generate the metadata uri.</param>
 /// <param name="itemTypeReference">The item type of the collection.</param>
 /// <param name="metadataUri">Returns the metadata URI for an operation (function, action, service op) based on its function import.</param>
 /// <returns>true if we have successfully built the metadata URI; false otherwise.</returns>
 internal override bool TryBuildCollectionMetadataUri(ODataCollectionStartSerializationInfo serializationInfo, IEdmTypeReference itemTypeReference, out Uri metadataUri)
 {
     DebugUtils.CheckNoExternalCallers();
     metadataUri = null;
     return(false);
 }
Пример #28
0
 private void CheckMemory()
 {
     DebugUtils.Log(Profiler.GetTotalReservedMemory().ToString());
     DebugUtils.Log(Profiler.GetTotalAllocatedMemory().ToString());
     DebugUtils.Log(Profiler.GetTotalUnusedReservedMemory().ToString());
 }
Пример #29
0
 /// <summary>
 /// Creates a metadata uri builder for the given base metadata document uri.
 /// DEVNOTE: specifically for unit testing.
 /// </summary>
 /// <param name="metadataDocumentUri">The non-null, absolute metadata document URI.</param>
 /// <param name="model">The Edm model instance.</param>
 /// <param name="writingResponse">if set to <c>true</c> indicates that a response is being written.</param>
 /// <returns>A new metadata uri builder.</returns>
 internal static ODataJsonLightMetadataUriBuilder CreateDirectlyFromUri(ODataMetadataDocumentUri metadataDocumentUri, IEdmModel model, bool writingResponse)
 {
     DebugUtils.CheckNoExternalCallers();
     Debug.Assert(metadataDocumentUri != null, "metadataDocumentUri != null");
     return(new DefaultMetadataUriBuilder(metadataDocumentUri, model, writingResponse));
 }
Пример #30
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="expandItems">The list of all expanded items at the next level down.</param>
 public Expansion(IEnumerable <ExpandedNavigationSelectItem> expandItems)
 {
     DebugUtils.CheckNoExternalCallers();
     this.expandItems = expandItems as ExpandedNavigationSelectItem[] ?? expandItems.ToArray();
 }