当前位置: 首页>>代码示例>>C#>>正文


C# Specification类代码示例

本文整理汇总了C#中Specification的典型用法代码示例。如果您正苦于以下问题:C# Specification类的具体用法?C# Specification怎么用?C# Specification使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Specification类属于命名空间,在下文中一共展示了Specification类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Converter

 public Converter(Specification S, G25.CG.Shared.CGdata cgd, G25.fgs F)
 {
     m_specification = S;
     m_cgd = cgd;
     m_fgs = F;
     m_fgs.InitArgumentPtrFromTypeNames(S);
 }
开发者ID:Sciumo,项目名称:gaigen,代码行数:7,代码来源:converter.cs

示例2: MarkdownReader

        public MarkdownReader(TextReader reader)
        {
            _reader = reader;
            _spec = new Specification();

            _modes.Push(new HeaderMode(_spec));
        }
开发者ID:storyteller,项目名称:Storyteller,代码行数:7,代码来源:MarkdownReader.cs

示例3: GetSpecification

        public Specification GetSpecification()
        {
            if (_resolvedSpecification == null)
            {
                //Lazy Load Specification
                if (String.IsNullOrEmpty(_specificationType))
                {
                    //No Specification specified, so get Default Specification For Type from Validation Catalog
                    _resolvedSpecification = ValidationCatalog.SpecificationContainer.TryGetSpecification(GetTypeToValidate());
                }
                else
                {
                    //Get Specification from Type
                    //Create type from string
                    var specType = System.Type.GetType(_specificationType);

                    if (specType == null)
                    {
                        //Type creation failed
                        return null;
                    }
                    else
                    {
                        //Query the Validation Catalog from the specification that matches type in the Catalog
                        _resolvedSpecification = ValidationCatalog.SpecificationContainer.GetAllSpecifications().Where(
                            x => x.GetType() == specType).FirstOrDefault();
                    }
                }
            }

            return _resolvedSpecification;
        }
开发者ID:TheProjecter,项目名称:specexpress,代码行数:32,代码来源:SpecificationManager.cs

示例4: GetComment

        private static string GetComment(Specification S, bool declOnly, G25.fgs FGS, G25.Operator op, G25.FloatType FT, bool assign)
        {
            StringBuilder SB = new StringBuilder();

            if ((S.OutputCpp()) && op.IsUnaryInPlace())
            {
                if (op.IsPrefix)
                {
                    SB.Append("returns (" + FGS.ArgumentVariableNames[0] + " = " + FGS.OutputName + "(" + FGS.ArgumentVariableNames[0] + "))");
                }
                else
                {
                    SB.Append("returns input value of " + FGS.ArgumentVariableNames[0] + ", but sets " + FGS.ArgumentVariableNames[0] + " to " + FGS.OutputName + "(" + FGS.ArgumentVariableNames[0] + ")");
                }
            }
            else if (assign)
            {
                SB.Append("returns (" + FGS.ArgumentVariableNames[0] + " = " + FGS.OutputName + "(" + FGS.ArgumentVariableNames[0]);
                SB.Append(", " + FGS.ArgumentVariableNames[1]);
                SB.Append("))");
            }
            else {
                SB.Append("returns " + FGS.OutputName + "(" + FGS.ArgumentVariableNames[0]);
                if (op.IsBinary())
                    SB.Append(", " + FGS.ArgumentVariableNames[1]);
                SB.Append(")");
            }

            return SB.ToString();
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:30,代码来源:operators.cs

示例5: GenerateCode

        public static List<string> GenerateCode(Specification S, G25.CG.Shared.CGdata cgd)
        {
            // get filename, list of generated filenames
            List<string> generatedFiles = new List<string>();

            if (!S.m_reportUsage) return generatedFiles;

            string sourceFilename = S.GetOutputPath(GetRawSourceFilename(S));
            generatedFiles.Add(sourceFilename);

            // get StringBuilder where all generated code goes
            StringBuilder SB = new StringBuilder();

            // output license, copyright
            G25.CG.Shared.Util.WriteCopyright(SB, S);
            G25.CG.Shared.Util.WriteLicense(SB, S);

            // using ...
            Util.WriteGenericUsing(SB, S);
            SB.AppendLine("using System.Collections.Generic;");
            SB.AppendLine("using System.Text;");

            // open namespace
            G25.CG.Shared.Util.WriteOpenNamespace(SB, S);

            cgd.m_cog.EmitTemplate(SB, "reportUsage");

            // close namespace
            G25.CG.Shared.Util.WriteCloseNamespace(SB, S);

            // write all to file
            G25.CG.Shared.Util.WriteFile(sourceFilename, SB.ToString());

            return generatedFiles;
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:35,代码来源:reportusage.cs

示例6: Complex_Specification_Should_Eval_ToTrue

 public void Complex_Specification_Should_Eval_ToTrue()
 {
     var testObject = new TestObject { FirstName = "John", LastName = "Doe", Age = 20 };
     var testSpec = new Specification<TestObject>(x => x.Age < 30) &
                    new Specification<TestObject>(x => x.FirstName.StartsWith("J"));
     Assert.That(testSpec.IsSatisfiedBy(testObject));
 }
开发者ID:jordanyaker,项目名称:ncommon,代码行数:7,代码来源:SpecificationTests.cs

示例7: ReadHeaderInformation

        public static Specification ReadHeaderInformation(XmlDocument document)
        {
            var spec = new Specification();
            var top = document.DocumentElement;
            spec.name = top.GetAttribute("name");

            var lifecycle = top.GetAttribute(LifecycleAtt);
            spec.Lifecycle = lifecycle.AsLifecycle();

            spec.id = top.ReadId();
            var maxRetries = top.GetAttribute(MaxRetries);
            spec.MaxRetries = maxRetries.IsEmpty() ? 0 : int.Parse(maxRetries);

            var lastUpdatedString = top.GetAttribute(LastUpdated);
            var lastUpdated = !lastUpdatedString.IsEmpty() ? DateTime.Parse(top.GetAttribute(LastUpdated)) : DateTime.Now;
            spec.LastUpdated = lastUpdated;

            var expirationPeriodString = top.GetAttribute(ExpirationPeriod);
            var expirationPeriod = expirationPeriodString.IsEmpty() ? 0 : int.Parse(expirationPeriodString);
            spec.ExpirationPeriod = expirationPeriod;

            spec.name = top.GetAttribute(Name);

            var tags = top.GetAttribute(TagsAtt);
            if (tags.IsNotEmpty())
            {
                spec.Tags.AddRange(tags.ToDelimitedArray());
            }
            return spec;
        }
开发者ID:jamesmanning,项目名称:Storyteller,代码行数:30,代码来源:XmlReader.cs

示例8: WriteCopy

        /// <summary>
        /// Writes a function to copy the value of one SMV struct to another, for all floating point types.
        /// </summary>
        /// <param name="S">Used for basis vector names and output language.</param>
        /// <param name="cgd">Intermediate data for code generation. Also contains plugins and cog.</param>
        public static void WriteCopy(Specification S, G25.CG.Shared.CGdata cgd)
        {
            StringBuilder declSB = cgd.m_declSB;
            StringBuilder defSB = (S.m_inlineSet) ? cgd.m_inlineDefSB : cgd.m_defSB;
            declSB.AppendLine("");
            defSB.AppendLine("");

            foreach (G25.FloatType FT in S.m_floatTypes)
            {
                foreach (G25.SMV smv in S.m_SMV)
                {
                    if (smv.NbNonConstBasisBlade == 0) continue;

                    String typeName = FT.GetMangledName(S, smv.Name);
                    String funcName = typeName + "_copy";
                    bool mustCast = false;

                    G25.fgs F = new G25.fgs(funcName, funcName, "", new String[] { smv.Name }, null, new String[] { FT.type }, null, null, null); // null, null, null = metricName, comment, options
                    F.InitArgumentPtrFromTypeNames(S);
                    bool computeMultivectorValue = false;
                    G25.CG.Shared.FuncArgInfo returnArgument = new G25.CG.Shared.FuncArgInfo(S, F, -1, FT, smv.Name, computeMultivectorValue);
                    int nbArgs = 1;
                    G25.CG.Shared.FuncArgInfo[] FAI = G25.CG.Shared.FuncArgInfo.GetAllFuncArgInfo(S, F, nbArgs, FT, null, computeMultivectorValue);

                    declSB.AppendLine("/** Copies " + typeName + ": " + FAI[0].Name + " = " + returnArgument.Name + " */");

                    RefGA.Multivector value = G25.CG.Shared.Symbolic.SMVtoSymbolicMultivector(S, smv, FAI[0].Name, FAI[0].Pointer);

                    bool staticFunc = false;
                    G25.CG.Shared.Functions.WriteAssignmentFunction(S, cgd,
                        S.m_inlineSet, staticFunc, "void", null, funcName, returnArgument, FAI, FT, mustCast, smv, returnArgument.Name, returnArgument.Pointer, value);
                }
            }
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:39,代码来源:smv.cs

示例9: CanImplement

        protected G25.SMV m_smv2 = null; ///< if function over SMV, type goes here

        #endregion Fields

        #region Methods

        /// <summary>
        /// Checks if this FunctionGenerator can implement a certain function.
        /// </summary>
        /// <param name="S">The specification of the algebra.</param>
        /// <param name="F">The function to be implemented.</param>
        /// <returns>true if 'F' can be implemented</returns>
        public override bool CanImplement(Specification S, G25.fgs F)
        {
            //String type F.GetArgumentTypeName(0, S.m_GMV.Name);
            return ((F.Name == "equals") && (F.MatchNbArguments(NB_ARGS)) &&
                G25.CG.Shared.Functions.NotMixSmvGmv(S, F, NB_ARGS, S.m_GMV.Name) &&
                G25.CG.Shared.Functions.NotUseOm(S, F, NB_ARGS, S.m_GMV.Name));
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:19,代码来源:equals.cs

示例10: WriteDefinition

        private static void WriteDefinition(StringBuilder SB, Specification S, G25.CG.Shared.CGdata cgd, FloatType FT, G25.Constant C)
        {
            // assume only SMV constants for now
            G25.SMV smv = C.Type as G25.SMV;
            ConstantSMV Csmv = C as ConstantSMV;

            // MANGLED_TYPENAME MANGLED_CONSTANT_NAME = {...}
            SB.Append(FT.GetMangledName(S, C.Type.GetName()));
            SB.Append(" ");
            SB.Append(FT.GetMangledName(S, C.Name));
            SB.Append(" = {");

            if (smv.NbNonConstBasisBlade == 0)
            {
                // 'C' does not allow empty structs, so there is a filler that must be initialized
                SB.Append("0");
            }
            else
            {
                if (S.m_coordStorage == COORD_STORAGE.ARRAY)
                    SB.Append("{");

                for (int c = 0; c < smv.NbNonConstBasisBlade; c++)
                {
                    if (c > 0) SB.Append(", ");
                    SB.Append(FT.DoubleToString(S, Csmv.Value[c]));
                }

                if (S.m_coordStorage == COORD_STORAGE.ARRAY)
                    SB.Append("}");
            }

            SB.AppendLine("};");
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:34,代码来源:constants.cs

示例11: CreateSyntheticSMVtype

        public static G25.VariableType CreateSyntheticSMVtype(Specification S, CGdata cgd, FloatType FT, RefGA.Multivector value)
        {
            // make up list of basis blades
            rsbbp.BasisBlade[] L = new rsbbp.BasisBlade[value.BasisBlades.Length];
            for (int i = 0 ; i < value.BasisBlades.Length; i++)
            {
                RefGA.BasisBlade B = value.BasisBlades[i];
                if (B.symScale == null) L[i] = new rsbbp.BasisBlade(new RefGA.BasisBlade(B.bitmap), B.scale); // constant value
                else L[i] = new rsbbp.BasisBlade(new RefGA.BasisBlade(B.bitmap)); // non-const value
            }

            // get other required info
            String name = "nameOfType";
            SMV.MULTIVECTOR_TYPE mvType = SMV.MULTIVECTOR_TYPE.MULTIVECTOR;
            String comment = "MISSING; PLEASE ADD TO SPECIFICATION";
            //String constantName = null;

            // create the type
            G25.SMV synSMV = new G25.SMV(name, L, mvType, comment);

            // throw exception
            throw new G25.UserException("Missing specialized multivector type.\n" +
                "Please add the following XML to the specification to fix the dependency:\n" +
                XML.SMVtoXmlString(S, synSMV));
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:25,代码来源:specializedreturntype.cs

示例12: AddOrganizationHierarchy

        public void AddOrganizationHierarchy(Organization parent,Organization child,OrganizationHierarchyType organizationHierarchyType)
        {
            Guard.Against<ArgumentNullException>(_organizationHierarchyRepository == null, "建構式需指定repository");

            OrganizationHierarchy organizationHierarchy =
                new OrganizationHierarchy()
                {
                    Level = 1,
                    ParentOrganizationId = parent.Id,
                    ChildOrganizationId = child.Id,
                    OrganizationHierarchyType = organizationHierarchyType
                };
            _organizationHierarchyRepository.SaveOrUpdate(organizationHierarchy);

            ISpecification<OrganizationHierarchy> specFindParents =
                new Specification<OrganizationHierarchy>(
                    s => s.ChildOrganizationId == parent.Id && s.OrganizationHierarchyType == organizationHierarchyType);

            IList<OrganizationHierarchy> allParents = _organizationHierarchyRepository.Query(specFindParents);

            foreach(var up in allParents)
            {
                OrganizationHierarchy hierarchy =
                   new OrganizationHierarchy()
                   {
                       Level = up.Level + 1,
                       ParentOrganizationId = up.ParentOrganizationId,
                       ChildOrganizationId = child.Id,
                       OrganizationHierarchyType = organizationHierarchyType
                   };
                _organizationHierarchyRepository.SaveOrUpdate(hierarchy);
            }
        }
开发者ID:ephebe,项目名称:MySecurity,代码行数:33,代码来源:OrganizationService.cs

示例13: GenerateBasicInfo

        public static void GenerateBasicInfo(StringBuilder SB, Specification S, G25.CG.Shared.CGdata cgd)
        {
            string accessModifier = Keywords.ConstAccessModifier(S);
            string accessModifierArr = Keywords.ConstArrayAccessModifier(S);
            string stringType = Keywords.StringType(S);
            string boolType = G25.CG.Shared.CodeUtil.GetBoolType(S);

            // dimension of space
            new G25.CG.Shared.Comment("The dimension of the space").Write(SB, S, 1);
            SB.AppendLine("\tpublic " + accessModifier + " int SpaceDim = " + S.m_dimension + ";");

            // number of groups in general multivector
            new G25.CG.Shared.Comment("Number of groups/grades of coordinates in a multivector").Write(SB, S, 1);
            SB.AppendLine("\tpublic " + accessModifier + " int NbGroups = " + S.m_GMV.NbGroups + ";");

            // Euclidean metric?
            new G25.CG.Shared.Comment("Is the metric of the space Euclidean? (false or true)").Write(SB, S, 1);
            SB.AppendLine("\tpublic " + accessModifier + " " + boolType + " MetricEuclidean = " +
                (S.GetMetric("default").m_metric.IsEuclidean() ? "true" : "false") + ";");

            // basis vector names
            new G25.CG.Shared.Comment("Names of the basis vectors.").Write(SB, S, 1);
            SB.AppendLine("\tpublic " + accessModifierArr + " " + stringType + "[] BasisVectorNames = new " + stringType + "[] {");
            SB.Append("\t\t");
            for (int i = 0; i < S.m_dimension; i++)
            {
                if (i > 0) SB.Append(", ");
                SB.Append("\"" + S.m_basisVectorNames[i] + "\"");
            }
            SB.AppendLine("");
            SB.AppendLine("\t};");
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:32,代码来源:source.cs

示例14: WriteFunctionShortcut

        /// <summary>
        /// Writes a shortcut for 'type', 'fgs'.
        /// </summary>
        /// <param name="SB">Where the code goes.</param>
        /// <param name="S">Used for basis vector names and output language.</param>
        /// <param name="cgd">Not used yet.</param>
        /// <param name="FT">Float point type of 'type'.</param>
        /// <param name="type">The type for which shortcuts should be written.</param>
        /// <param name="fgs"></param>
        /// <param name="FAI"></param>
        public static void WriteFunctionShortcut(StringBuilder SB, Specification S, G25.CG.Shared.CGdata cgd, FloatType FT, G25.VariableType type,
            G25.fgs fgs, FuncArgInfo[] FAI)
        {
            int nbTabs = 1;

            FuncArgInfo[] tailFAI = getTail(FAI);

            string shortcutCall = getShortcutCall(S, fgs, tailFAI);

            SB.AppendLine("");

            // output comment
            new Comment("shortcut to " + shortcutCall).Write(SB, S, nbTabs);

            bool inline = false;
            bool staticFunc = false;
            string returnType = FT.GetMangledName(S, fgs.ReturnTypeName);
            FuncArgInfo returnArgument = null;

            SB.Append('\t', nbTabs);
            Functions.WriteDeclaration(SB, S, cgd,
                inline, staticFunc, returnType, fgs.OutputName,
                returnArgument, tailFAI);
            SB.AppendLine(" {");

            SB.Append('\t', nbTabs+1);
            SB.Append("return ");
            SB.Append(shortcutCall);
            SB.AppendLine(";");

            SB.Append('\t', nbTabs);
            SB.AppendLine("}");
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:43,代码来源:shortcut.cs

示例15: GetDualCode

 /// <summary>
 /// Returns the code for dualization wrt to whole space using metric <c>M</c>.
 /// The code is composed of calls to functions generated by <c>WriteGmvDualParts()</c>.
 /// 
 /// This function uses <c>cdg.m_gmvDualPartFuncNames</c>, but only to check whether a
 /// geometric product of some group with the pseudoscalar will get non-zero results in some
 /// other group.
 /// 
 /// The returned code is only the body. The function declaration is not included.
 /// </summary>
 /// <param name="S">Specification of algebra (used for general multivector type, output language).</param>
 /// <param name="cgd">Used for <c>m_gmvDualPartFuncNames</c>.</param>
 /// <param name="FT">Floating point type.</param>
 /// <param name="M">The metric of the dual.</param>
 /// <param name="FAI">Info about function arguments</param>
 /// <param name="resultName">Name of variable where the result goes (in the generated code).</param>
 /// <param name="dual">When true, 'dual' is generated, otherwise, 'undual' is generated.</param>
 /// <returns>code for the requested product type.</returns>
 public static string GetDualCode(Specification S, G25.CG.Shared.CGdata cgd, G25.FloatType FT, 
     G25.Metric M, G25.CG.Shared.FuncArgInfo[] FAI, string resultName, bool dual)
 {
     if (S.OutputCppOrC())
         return GetDualCodeCppOrC(S, cgd, FT, M, FAI, resultName, dual);
     else return GetDualCodeCSharpOrJava(S, cgd, FT, M, FAI, resultName, dual);
 }
开发者ID:Sciumo,项目名称:gaigen,代码行数:25,代码来源:dual_parts.cs


注:本文中的Specification类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。