Exemplo n.º 1
0
        private async Task <object> InvokeCommand(object receivedParameter, AttributeContent attributeContent)
        {
            var declaringType = attributeContent.Method.DeclaringType;

            Logger.LogInformation(
                "Invoking command '{1}' in type '{2}'",
                attributeContent,
                declaringType.FullName);

            try
            {
                var instance = ActivatorUtilities.GetServiceOrCreateInstance(_serviceProvider, declaringType);

                return(IsTask(attributeContent.Method)
                    ? await(dynamic) attributeContent.Method.Invoke(instance, new[] { receivedParameter })
                    : await Task.Run(() => attributeContent.Method.Invoke(instance, new[] { receivedParameter })));
            }
            catch (Exception ex)
            {
                Logger.LogError("Exception was thrown for command '{1}' in type {2}. Exception message: {3}. InnerException: {4}",
                                attributeContent.Key,
                                declaringType.FullName,
                                ex.Message,
                                ex.InnerException);


                throw;
            }
        }
        private void InvokeTopic(object receivedParameter, string receivedTopic, AttributeContent attributeContent)
        {
            var declaringType = attributeContent.Method.DeclaringType;

            Logger.LogInformation(
                "Invoking event '{1}' in type '{2}'",
                attributeContent.Key,
                declaringType.FullName);

            try
            {
                var instance = ActivatorUtilities.GetServiceOrCreateInstance(_serviceProvider, declaringType);
                attributeContent.Method.Invoke(instance, new[] { receivedParameter });
            }
            catch (TargetInvocationException ex)
            {
                Logger.LogError(
                    ex.InnerException,
                    "Exception was thrown for event '{1}' in type {2}",
                    attributeContent.Key,
                    declaringType.FullName);

                throw;
            }
        }
Exemplo n.º 3
0
 protected ConceptualItem()
 {
     _revNumber       = 1;
     _isVisible       = true;
     _includesTopicId = false;
     _topicId         = String.Empty;
     _topicTitle      = String.Empty;
     _topicVersion    = new Version(1, 0, 0, 0);
     _topicTocTitle   = String.Empty;
     _topicTypeId     = String.Empty;
     _attributes      = new AttributeContent();
     _keywords        = new KeywordContent();
 }
 internal XdrBuilder(XmlReader reader, XmlNamespaceManager curmgr, SchemaInfo sinfo, string targetNamspace, XmlNameTable nameTable, SchemaNames schemaNames, ValidationEventHandler eventhandler)
 {
     this._SchemaInfo = sinfo;
     this._TargetNamespace = targetNamspace;
     this._reader = reader;
     this._CurNsMgr = curmgr;
     this.validationEventHandler = eventhandler;
     this._StateHistory = new HWStack(10);
     this._ElementDef = new ElementContent();
     this._AttributeDef = new AttributeContent();
     this._GroupStack = new HWStack(10);
     this._GroupDef = new GroupContent();
     this._NameTable = nameTable;
     this._SchemaNames = schemaNames;
     this._CurState = S_SchemaEntries[0];
     this.positionInfo = PositionInfo.GetPositionInfo(this._reader);
     this.xmlResolver = new XmlUrlResolver();
 }
Exemplo n.º 5
0
        /// <summary>
        /// The creates the configuration information or settings required by the
        /// target component for the build process.
        /// </summary>
        /// <param name="group">
        /// A build group, <see cref="BuildGroup"/>, representing the documentation
        /// target for configuration.
        /// </param>
        /// <param name="writer">
        /// An <see cref="XmlWriter"/> object used to create one or more new
        /// child nodes at the end of the list of child nodes of the current node.
        /// </param>
        /// <returns>
        /// Returns <see langword="true"/> for a successful configuration;
        /// otherwise, it returns <see langword="false"/>.
        /// </returns>
        /// <remarks>
        /// The <see cref="XmlWriter"/> writer passed to this configuration object
        /// may be passed on to other configuration objects, so do not close or
        /// dispose it.
        /// </remarks>
        public override bool Configure(BuildGroup group, XmlWriter writer)
        {
            BuildExceptions.NotNull(group, "group");
            BuildExceptions.NotNull(writer, "writer");

            if (!this.Enabled || !this.IsInitialized)
            {
                return(false);
            }

            Debug.Assert(_settings != null, "The settings object is required.");
            if (_settings == null || _context == null)
            {
                return(false);
            }

            BuildGroupContext groupContext = _context.GroupContexts[group.Id];

            if (groupContext == null)
            {
                throw new BuildException(
                          "The group context is not provided, and it is required by the build system.");
            }

            //<component type="Sandcastle.Components.ReferencePostTransComponent" assembly="$(SandAssistComponent)">
            //    <paths outputPath=".\Output\"/>
            //    <attributes>
            //        <attribute name="DocSet" value="NETFramework" />
            //        <attribute name="DocSet" value="NETCompactFramework"/>
            //    </attributes>
            //    <scripts>
            //        <IncludeItem item="assistScripts" />
            //    </scripts>
            //    <styles>
            //        <!-- Include the various styles used by the Sandcastle Assist -->
            //        <IncludeItem item="codeStyle" />
            //        <IncludeItem item="assistStyle" />
            //    </styles>
            //    <header>
            //        <!-- Include the logo image support -->
            //        <IncludeItem item="logoImage" />
            //        <!--<tables>
            //            <table name="" operation="" />
            //        </tables>-->
            //    </header>
            //</component>

            BuildFeedback feeback = _settings.Feedback;

            Debug.Assert(feeback != null, "Feedback object cannot be null (or Nothing).");
            if (feeback == null)
            {
                return(false);
            }
            BuildStyle buildStyle = _settings.Style;

            Debug.Assert(buildStyle != null, "The style object cannot be null (or Nothing).");
            if (buildStyle == null)
            {
                return(false);
            }

            writer.WriteStartElement("paths");  //start: paths
            writer.WriteAttributeString("outputPath", @".\Output\");
            writer.WriteEndElement();           //end: paths

            AttributeContent attributes = _settings.Attributes;

            if (attributes != null && attributes.Count != 0)
            {
                writer.WriteStartElement("attributes");  //start: attributes
                for (int i = 0; i < attributes.Count; i++)
                {
                    AttributeItem attribute = attributes[i];
                    if (attribute.IsEmpty)
                    {
                        continue;
                    }

                    writer.WriteStartElement("attribute");  //start: attribute
                    writer.WriteAttributeString("name", attribute.Name);
                    writer.WriteAttributeString("value", attribute.Value);
                    writer.WriteEndElement();            //end: attribute
                }
                writer.WriteEndElement();                //end: attributes
            }

            writer.WriteStartElement("scripts");  //start: scripts
            ScriptContent scriptContent = buildStyle.Scripts;

            if (scriptContent != null && !scriptContent.IsEmpty)
            {
                for (int i = 0; i < scriptContent.Count; i++)
                {
                    ScriptItem scriptItem = scriptContent[i];
                    // a. Empty item is no use.
                    // b. Overriding scripts are added to the documentation
                    //    by the transform.
                    if (scriptItem.IsEmpty || scriptItem.Overrides)
                    {
                        continue;
                    }

                    writer.WriteStartElement("script");  //start: script
                    writer.WriteAttributeString("file", scriptItem.ScriptFile);
                    writer.WriteAttributeString("condition", scriptItem.Condition);
                    writer.WriteEndElement();            //end: script
                }
            }
            writer.WriteEndElement();            //end: scripts

            writer.WriteStartElement("styles");  //start: styles
            StyleSheetContent styleContent = buildStyle.StyleSheets;

            if (styleContent != null && !styleContent.IsEmpty)
            {
                for (int i = 0; i < styleContent.Count; i++)
                {
                    StyleSheetItem styleItem = styleContent[i];
                    // a. Empty item is no use.
                    // b. Overriding styles are added to the documentation
                    //    by the transform.
                    if (styleItem.IsEmpty || styleItem.Overrides)
                    {
                        continue;
                    }

                    writer.WriteStartElement("style");  //start: style
                    writer.WriteAttributeString("file", styleItem.StyleFile);
                    writer.WriteAttributeString("condition", styleItem.Condition);
                    writer.WriteEndElement();           //end: style
                }
            }
            writer.WriteEndElement();            //end: styles

            // Let the Feedback option object configure itself...
            feeback.Configure(group, writer);

            // Write roots to namespaces conversion handler...
            writer.WriteStartElement("rootNamespaces"); // start: rootNamespaces
            writer.WriteAttributeString("id", group.Id);

            string rootNamespacesFile = Path.Combine(_context.WorkingDirectory,
                                                     groupContext["$RootNamespaces"]);

            if (File.Exists(rootNamespacesFile))
            {
                writer.WriteAttributeString("source", rootNamespacesFile);
            }
            writer.WriteEndElement();                   //end: rootNamespaces

            return(true);
        }
Exemplo n.º 6
0
 public AttributeNode(string name, AttributeContent value)
 {
     Name = name;
     Value = value;
 }
Exemplo n.º 7
0
        private static void AssertAttributeContent(AttributeContent expected, AttributeContent actual)
        {
            if (expected == null)
            {
                Assert.Null(actual);
                return;
            }

            Assert.NotNull(actual);

            var eConst = expected as ConstantAttributeContent;
            var eComp = expected as CompositeAttributeContent;
            var eEvaluate = expected as AttributeContentStatement;
            if (eConst != null)
            {
                Assert.IsType<ConstantAttributeContent>(actual);
                Assert.Equal(eConst.Text, ((ConstantAttributeContent) actual).Text);
            }
            else if (eComp != null)
            {
                var aComp = Assert.IsType<CompositeAttributeContent>(actual);
                AssertAttributeContentChildren(eComp.ContentParts, aComp.ContentParts);
            }
            else if (eEvaluate != null)
            {
                var eActual = Assert.IsType<AttributeContentStatement>(actual);
                HandlebarsExpressionAssert.AssertExpression(eEvaluate.Expression, eActual.Expression);

                AssertAttributeContentChildren(eEvaluate.Children, eActual.Children);
            }
            else
                throw new Exception("Unexpected type");
        }
Exemplo n.º 8
0
 /// <summary>
 /// Determines whether the specified analysis represents an empty value, collection or block
 /// </summary>
 /// <param name="analysis">The analysis.</param>
 /// <returns>
 ///   <c>true</c> if [is empty value] [the specified analysis]; otherwise, <c>false</c>.
 /// </returns>
 private static bool IsEmptyValue(AttributeContent analysis)
 {
     return(EmptyAttributeAnalysisResults.Contains(analysis));
 }
Exemplo n.º 9
-1
 internal XdrBuilder(
                    XmlReader reader,
                    XmlNamespaceManager curmgr,
                    SchemaInfo sinfo,
                    string targetNamspace,
                    XmlNameTable nameTable,
                    SchemaNames schemaNames,
                    ValidationEventHandler eventhandler
                    )
 {
     _SchemaInfo = sinfo;
     _TargetNamespace = targetNamspace;
     _reader = reader;
     _CurNsMgr = curmgr;
     _validationEventHandler = eventhandler;
     _StateHistory = new HWStack(StackIncrement);
     _ElementDef = new ElementContent();
     _AttributeDef = new AttributeContent();
     _GroupStack = new HWStack(StackIncrement);
     _GroupDef = new GroupContent();
     _NameTable = nameTable;
     _SchemaNames = schemaNames;
     _CurState = s_schemaEntries[0];
     _positionInfo = PositionInfo.GetPositionInfo(_reader);
     _xmlResolver = null;
 }