Exemple #1
0
        public IWorkshopTree Build()
        {
            // Setup inline-recursive handler.
            RecursiveStack stack = null;

            if (!Determiner.IsSubroutine() && Determiner.IsRecursive())
            {
                stack = new RecursiveStack(this, Determiner.GetStackIdentifier());
                stack.Init();
                ActionSet.Translate.MethodStack.Add(stack);
            }

            ModifySet(a => a.PackThis());
            SetupReturnHandler();        // Setup the return handler.
            SetParameters();             // Set the parameters.
            stack?.StartRecursiveLoop(); // Start the recursion loop.
            ParseContents();             // Parse the lookup table.
            stack?.EndRecursiveLoop();   // End the recursive loop.

            if (stack != null)
            {
                ActionSet.Translate.MethodStack.Remove(stack);                // Remove recursion info from the stack.
            }
            return(ReturnHandler.GetReturnedValue());
        }
Exemple #2
0
        public void DeterminerConstructorTest()
        {
            var text   = "the";
            var target = new Determiner(text);

            Check.That(target.Text).IsEqualTo(text);
            Check.That(target.Determines).IsNull();
        }
        public override void ToString(StringBuilder stringBuilder)
        {
            if (stringBuilder is null)
            {
                throw new ArgumentNullException(nameof(stringBuilder));
            }

            stringBuilder.AppendMetaPropertyContent("og:title", Title);
            if (Type != OpenGraphType.Website)
            {
                stringBuilder.AppendMetaPropertyContent("og:type", Type.ToLowercaseString());
            }
            stringBuilder.AppendMetaPropertyContent("og:url", Url);
            foreach (OpenGraphMedia medium in Media)
            {
                stringBuilder.AppendMetaPropertyContent("og:image", medium.Url);
            }
            stringBuilder.AppendMetaPropertyContentIfNotNull("og:description", Description);
            stringBuilder.AppendMetaPropertyContentIfNotNull("og:site_name", SiteName);
            if (Determiner != 0)
            {
                stringBuilder.AppendMetaPropertyContent("og:determiner", Determiner.ToLowercaseString());
            }
            if (Locale != null)
            {
                stringBuilder.AppendMetaPropertyContent("og:locale", Locale);
                if (AlternateLocales != null)
                {
                    foreach (string alternateLocale in AlternateLocales)
                    {
                        stringBuilder.AppendMetaPropertyContent("og:locale:alternate", alternateLocale);
                    }
                }
            }
            if (SeeAlso != null)
            {
                foreach (string item in SeeAlso)
                {
                    stringBuilder.AppendMetaPropertyContent("og:see_also", item);
                }
            }
            if (FacebookAdministrators != null)
            {
                foreach (string facebookAdministrator in FacebookAdministrators)
                {
                    stringBuilder.AppendMetaPropertyContentIfNotNull("fb:admins", facebookAdministrator);
                }
            }
            stringBuilder.AppendMetaPropertyContentIfNotNull("fb:app_id", FacebookApplicationId);
            stringBuilder.AppendMetaPropertyContentIfNotNull("fb:profile_id", FacebookProfileId);

            stringBuilder.AppendMetaPropertyContentIfNotNull("article:content_type", ContentType);
            stringBuilder.AppendMetaPropertyContentIfNotNull("article:category", Category);
            stringBuilder.AppendMetaPropertyContentIfNotNull("article:industry", Industry);
            stringBuilder.AppendMetaPropertyContentIfNotNull("article:published_time", PublishedTime);
            stringBuilder.AppendMetaPropertyContentIfNotNull("article:modified_time", ModifiedTime);
            stringBuilder.AppendMetaPropertyContentIfNotNull("article:expiration_time", ExpirationTime);
        }
Exemple #4
0
        public void BindDeterminerTest()
        {
            var target     = new CommonSingularNoun("dog");
            var determiner = new Determiner("the");

            target.BindDeterminer(determiner);
            Check.That(target.Determiner).IsEqualTo(determiner);
            Check.That(determiner.Determines).IsEqualTo(target);
        }
Exemple #5
0
 void SetParameters()
 {
     if (!Determiner.IsSubroutine())
     {
         for (int i = 0; i < _parameters.Length; i++)
         {
             _parameters[i].Set(ActionSet, CallHandler.ParameterValues[i]);
         }
     }
 }
Exemple #6
0
        public void DeterminesTest()
        {
            var     text     = "the";
            var     target   = new Determiner(text);
            IEntity expected = new CommonSingularNoun("organization");
            IEntity actual;

            target.Determines = expected;
            actual            = target.Determines;
            Check.That(actual).IsEqualTo(expected);
        }
Exemple #7
0
        public IWorkshopTree Call()
        {
            // Call subroutine.
            if (Determiner.IsSubroutine())
            {
                var subroutineInfo = Determiner.GetSubroutineInfo();
                SetSubroutineParameters(subroutineInfo);

                // Store the object the subroutine is executing with.
                if (Determiner.IsObject())
                {
                    // Normal
                    if (!Determiner.IsRecursive())
                    {
                        ActionSet.AddAction(subroutineInfo.ObjectStore.SetVariable((Element)ActionSet.CurrentObject));
                    }
                    // Recursive: Stack
                    else
                    {
                        ActionSet.AddAction(subroutineInfo.ObjectStore.ModifyVariable(Operation.AppendToArray, Element.CreateArray(ActionSet.CurrentObject)));
                    }
                }

                ExecuteSubroutine(subroutineInfo.Subroutine, CallHandler.ParallelMode);
                return(subroutineInfo.ReturnHandler.GetReturnedValue());
            }
            // Inline function
            else
            {
                // Recursive stack.
                if (Determiner.IsRecursive())
                {
                    var lastCall = Determiner.GetExistingRecursiveStack(ActionSet.Translate.MethodStack);

                    // Function is not yet on the stack.
                    if (lastCall == null)
                    {
                        return(Build());
                    }
                    else // Recursive call.
                    {
                        lastCall.RecursiveCall(CallHandler, ActionSet);
                        return(ActionSet.ReturnHandler.GetReturnedValue());
                    }
                }
                else
                {
                    return(Build());
                }
            }
        }
Exemple #8
0
 public void Subcall(ActionSet actionSet, IFunctionHandler function)
 {
     // We use a new actionSet rather than _actionSet in case the caller needs special adjustments.
     if (function.IsSubroutine())
     {
         ExecuteSubroutine(function, CallHandler?.ParallelMode ?? CallParallel.NoParallel);
         // Bridge the returned value.
         if (Determiner.ReturnsValue())
         {
             ReturnHandler.ReturnValue(function.GetSubroutineInfo().ReturnHandler.GetReturnedValue());
         }
     }
     else
     {
         function.ParseInner(actionSet);
     }
 }
Exemple #9
0
        public static void Test_Determinant()
        {
            while (true)
            {
                string resGenre  = "";
                string resNombre = "";

                Console.Write("Déterminant ?\t");
                Determiner determiner = new Determiner(Console.ReadLine());
                if (determiner.Gender == "M")
                {
                    resGenre = "masculin";
                }
                else if (determiner.Gender == "F")
                {
                    resGenre = "féminin";
                }
                else if (determiner.Gender == "N")
                {
                    resGenre = "neutre";
                }
                else
                {
                    resGenre = "inconnu";
                }
                if (determiner.Number == "S")
                {
                    resNombre = "singulier";
                }
                else if (determiner.Number == "P")
                {
                    resNombre = "pluriel";
                }
                else
                {
                    resNombre = "inconnu";
                }
                Console.WriteLine(determiner + " est un " + determiner.Type1 + " " + determiner.Type2 + " " + resGenre + " " + resNombre);
                Console.WriteLine("\t" + MaleSingularOf(determiner));
                Console.WriteLine("\t" + FemaleSingularOf(determiner));
                Console.WriteLine("\t" + MalePlurialOf(determiner));
                Console.WriteLine("\t" + FemalePlurialOf(determiner));
                Console.WriteLine();
            }
        }
Exemple #10
0
 void ParseContents() => Determiner.GetLookupTable().Build(this);
Exemple #11
0
 void SetupReturnHandler()
 {
     ReturnHandler = new ReturnHandler(ActionSet, Determiner.GroupName(), Determiner.MultiplePaths());
     ModifySet(a => a.New(ReturnHandler));
 }
Exemple #12
0
        /// <summary>
        ///     Appends a HTML-encoded string representing this instance to the
        ///     <paramref name="stringBuilder" /> containing the Open Graph meta tags.
        /// </summary>
        /// <param name="stringBuilder"> The string builder. </param>
        public virtual void ToString(StringBuilder stringBuilder)
        {
            Validate();

            // Three required tags.
            stringBuilder.AppendMetaPropertyContent("og:title", Title);
            if (Type != OpenGraphType.Website)
            {
                stringBuilder.AppendMetaPropertyContent("og:type", Type.ToLowercaseString());
            }

            if (Url == null)
            {
                Url = GetRequestUrl();
            }

            stringBuilder.AppendMetaPropertyContent("og:url", Url);

            // Add image, video and audio tags.
            MainImage.ToString(stringBuilder);
            if (Media != null)
            {
                foreach (var media in Media)
                {
                    media.ToString(stringBuilder);
                }
            }

            stringBuilder.AppendMetaPropertyContentIfNotNull("og:description", Description);
            stringBuilder.AppendMetaPropertyContentIfNotNull("og:site_name", SiteName);

            if (Determiner != OpenGraphDeterminer.Blank)
            {
                stringBuilder.AppendMetaPropertyContent("og:determiner", Determiner.ToLowercaseString());
            }

            if (Locale != null)
            {
                stringBuilder.AppendMetaPropertyContent("og:locale", Locale);

                if (AlternateLocales != null)
                {
                    foreach (var locale in AlternateLocales)
                    {
                        stringBuilder.AppendMetaPropertyContent("og:locale:alternate", locale);
                    }
                }
            }

            if (SeeAlso != null)
            {
                foreach (var seeAlso in SeeAlso)
                {
                    stringBuilder.AppendMetaPropertyContent("og:see_also", seeAlso);
                }
            }

            if (FacebookAdministrators != null)
            {
                foreach (var facebookAdministrator in FacebookAdministrators)
                {
                    stringBuilder.AppendMetaPropertyContentIfNotNull("fb:admins", facebookAdministrator);
                }
            }

            stringBuilder.AppendMetaPropertyContentIfNotNull("fb:app_id", FacebookApplicationId);
            stringBuilder.AppendMetaPropertyContentIfNotNull("fb:profile_id", FacebookProfileId);
        }