예제 #1
0
    // Static method Main is the entry point method.
    public static void Main()
    {
        Stringer myStringInstance = new Stringer();

        Console.WriteLine("Client code executes");
        myStringInstance.StringerMethod();
    }
예제 #2
0
        private static @string ToString(object arg)
        {
        #if NET5_0
            Stringer?stringer = arg as Stringer ?? Stringer.As(arg);
        #else
            Stringer?stringer = arg as Stringer ?? typeof(Stringer <>).CreateInterfaceHandler <Stringer>(arg);;
        #endif

            if (!(stringer is null))
            {
                return(stringer.String());
            }

        #if NET5_0
            error?err = arg as error ?? error.As(arg);
        #else
            error?err = arg as error ?? typeof(error <>).CreateInterfaceHandler <error>(arg);
        #endif

            if (!(err is null))
            {
                return(err.Error());
            }

            if (arg is bool)
            {
                return(arg.ToString() !.ToLowerInvariant());
            }

            return(arg?.ToString() ?? "<nil>");
        }
예제 #3
0
        // ----------------------- ToMimeString ---------------------------
        public string ToMimeString(string InCharSet)
        {
            string friendlyResults = null;
            string addressResults  = null;
            string results         = null;

            // message line encode the friendly name.
            if (Stringer.IsNotEmpty(FriendlyName))
            {
                MimeHeaderLineBuilder friendly = new MimeHeaderLineBuilder( );
                friendly.Traits
                .SetEncoderCharSet(InCharSet)
                .SetOtherEncodeChars("<>\"\'");
                friendly.Append(FriendlyName);
                friendlyResults = friendly.ToEncodedString( );
            }

            // message line encode the email address
            MimeHeaderLineBuilder lb = new MimeHeaderLineBuilder( );

            lb.Traits
            .SetEncoderCharSet(InCharSet);
            lb.Append(" <" + Address + ">");
            addressResults = lb.ToEncodedString( );

            results =
                MimeCommon.ConcatMessageLine(lb.Traits, friendlyResults, addressResults);
            return(results);
        }
예제 #4
0
        // ------------------------- MessageLineSplitter --------------------------
        // split the mime encoded message into its text line contents.
        public static string[] MessageLineSplitter(string InStream)
        {
            string unfoldedStream = Unfold(InStream);

            string[] results = Stringer.Split(unfoldedStream, "\r\n");
            return(results);
        }
예제 #5
0
        public static string DecodeXmlString(string InText)
        {
            int           lx;
            StringBuilder sb = new StringBuilder(InText.Length);
            int           ix = 0;

            while (ix < InText.Length)
            {
                int fx = InText.IndexOf('&', ix);
                if (fx == -1)
                {
                    sb.Append(InText.Substring(ix));
                    break;
                }

                // copy text up to the "&" asis to the decoded output.
                if (fx > ix)
                {
                    lx = fx - ix;
                    sb.Append(InText.Substring(ix, lx));
                }
                ix = fx;

                // test that an encoded char has been found.
                string encodedText = Stringer.SubstringPadded(InText, ix, 6);
                if (encodedText.Substring(0, 4) == "&gt;")
                {
                    sb.Append('>');
                    ix += 4;
                }
                else if (encodedText.Substring(0, 4) == "&lt;")
                {
                    sb.Append('<');
                    ix += 4;
                }
                else if (encodedText.Substring(0, 5) == "&amp;")
                {
                    sb.Append('&');
                    ix += 5;
                }
                else if (encodedText.Substring(0, 6) == "&apos;")
                {
                    sb.Append('\'');
                    ix += 6;
                }
                else if (encodedText.Substring(0, 6) == "&quot;")
                {
                    sb.Append('"');
                    ix += 6;
                }

                // unexpected encoded character.
                else
                {
                    throw new ApplicationException("unexpected xml encoded character " + encodedText);
                }
            }

            return(sb.ToString());
        }
예제 #6
0
        public void SetValue(XmlAttributeCollection inValue)
        {
            constructList.Add(new ItemConstruct());

            // 构造函数
            ItemConstruct construct = new ItemConstruct(new List <string>()
            {
                "System.String"
            });

            construct.Struct.Statements.Add(Line("string[] ss", "inArg0.Split(\'^\')"));

            classer.CustomAttributes.Add(new CodeAttributeDeclaration("ProtoContract"));
            for (int i = 0; i < inValue.Count; i++)
            {
                fieldList.Add(new ItemField(inValue[i].Name, inValue[i].Value, MemberAttributes.Private));

                ItemProperty item = new ItemProperty(inValue[i].Name);
                item.SetGetName();
                item.SetSetName();
                item.SetValueType(inValue[i].Value);
                item.SetModifier(MemberAttributes.Public | MemberAttributes.Final);
                item.SetField("ProtoMember", (i + 1).ToString());
                propertyList.Add(item);

                Type t = Stringer.ToType(inValue[i].Value);

                string right = t == typeof(System.String) ? "ss[" + i + "]" :
                               t == typeof(System.UInt32) ? "uint.Parse(ss[" + i + "])" :
                               t == typeof(System.Single) ? "float.Parse(ss[" + i + "])" : "new " + t.ToString() + "(inValues[" + i + "])";
                construct.Struct.Statements.Add(Line("_" + Stringer.FirstLetterLower(inValue[i].Name), right));
            }
            constructList.Add(construct);
            Create();
        }
예제 #7
0
        static void Test()
        {
            //Calculate x+y
            var summ  = new Summator();
            var summ2 = new Summator();
            var summ3 = new Summator();
            var str   = new Stringer();

            var one   = new InPoint(new IntColor(1));
            var one2  = new OutPoint(new IntColor(1));
            var two   = new InPoint(new IntColor(2));
            var three = new OutPoint(new IntColor(3));
            var four  = new OutPoint(new IntColor(5));
            var mix1  = new MixNode();

            one.ConnectTo(summ);
            two.ConnectTo(summ);

            one2.ConnectTo(summ).ConnectTo(summ2);
            three.ConnectTo(summ2).ConnectTo(str);

            four.ConnectTo(summ2);
            summ.ConnectTo(summ3);
            summ2.ConnectTo(summ3);
            summ3.ConnectTo(str);
            new OutPoint(new IntColor(6)).ConnectTo(str);
            //str.ConnectTo(mix1);
            // new OutPoint(new StringColor("abba")).ConnectTo(mix1);/**/
            // graph.Add(new ColorableClass[] { one, two, one2, three });
            graph.Add(new ConnectionPoint[] { one, two, one2, three, four });
            graph.OnFinish += OnFinish;
            graph.StartAsync();
        }
예제 #8
0
 /// <summary>
 /// 特性声明
 /// <para>eg. [Serializable]</para>
 /// </summary>
 /// <param name="inName">特性名</param>
 /// <param name="inValue">特性值</param>
 public void SetField(string inName, string inValue)
 {
     if (Stringer.IsNumber(inValue))
     {
         property.CustomAttributes.Add(new CodeAttributeDeclaration(inName, new CodeAttributeArgument(new CodePrimitiveExpression(int.Parse(inValue)))));
     }
 }
예제 #9
0
        public static AcColumnInfo Parse(string InString)
        {
            AcColumnInfo info = new AcColumnInfo();

            CsvCursor csv = new CsvCursor(InString);

            // ColumnName
            csv.NextValue();
            info.ColumnName = csv.ItemValue;

            // HeadingText
            csv.NextValue();
            info.HeadingText = csv.ItemValue;

            // AllowedValues
            csv.NextValue();
            if (csv.ItemValue != null)
            {
                info.AllowedValues =
                    Stringer.ParseSerializedListOfString(csv.ItemValue);
            }

            // ErrorText
            csv.NextValue();
            info.ErrorText = csv.ItemValue;

            return(info);
        }
예제 #10
0
        void FtpDirTree_BeforeExpand(object sender, TreeViewCancelEventArgs e)
        {
            TreeNode node      = e.Node;
            Cursor   wasCursor = null;

            // the tag of the node contains the full path of the ftp directory.
            FullPath filePath = (FullPath)node.Tag;

            // calc if the node contains a single, empty node.
            if ((node.Nodes.Count == 1) &&
                (Stringer.GetFromStringObject(node.Nodes[0].Tag, "") == "empty"))
            {
                node.Nodes.Clear();

                try
                {
                    wasCursor      = Cursor.Current;
                    Cursor.Current = Cursors.WaitCursor;
                    mFtpDirTree.BeginUpdate();
                    FtpDirTree_FillDirNode(filePath, node);
                }
                finally
                {
                    mFtpDirTree.EndUpdate();
                    Cursor.Current = wasCursor;
                }
            }
        }
예제 #11
0
 public ItemProperty(string inName)
 {
     property        = new CodeMemberProperty();
     property.HasGet = false;
     property.HasSet = false;
     property.Name   = Stringer.FirstLetterUp(inName);
 }
예제 #12
0
        // --------------------------- RunList --------------------------------
        // run the List command on the server
        public MailDropMessages RunList( )
        {
            MailDropMessages messages = new MailDropMessages( );

            string[] listLines = null;
            SockEx.SendReceive("LIST" + PopConstants.CrLf);
            while (true)
            {
                if (ResponseIsPopTerminated(SockEx.ResponseBuilder) == true)
                {
                    break;
                }
                SockEx.SleepThenReadMoreAvailableData(1000);
            }
            listLines = Stringer.Split(SockEx.ResponseMessage, NetworkConstants.CrLf);

            // parse the list line output into an arraylist of MailDropMessages.
            for (int Ix = 0; Ix < listLines.Length; ++Ix)
            {
                string line = listLines[Ix];
                if ((line[0] == '+') || (line[0] == '.'))
                {
                    continue;
                }
                messages.AddMessage(new MailDropMessage(line));
            }

            return(messages);
        }
예제 #13
0
        private static string PairToString(KeyValuePair <string, AcColumnInfo> InPair)
        {
            string strPair =
                Stringer.ToParseableString(InPair.Key) + ", [" +
                InPair.Value.ToString() + "]";

            return(strPair);
        }
예제 #14
0
 public ToCSharpBase(string inSpace, string inClassName, string inFolderName)
 {
     spaceName       = inSpace.Trim();
     className       = Stringer.FirstLetterUp(inClassName);
     folderName      = inFolderName;
     classer         = new CodeTypeDeclaration(className);
     classer.IsClass = true;
 }
예제 #15
0
        private static string PairToString(KeyValuePair <string, string> InPair)
        {
            string strPair =
                "[" + Stringer.ToParseableString(InPair.Key) + "," +
                Stringer.ToParseableString(InPair.Value) + "]";

            return(strPair);
        }
예제 #16
0
 public Tools()
 {
     Writer     = new IO.FConsole();
     FileReader = new IO.FileReader();
     FileWriter = new IO.FileWriter();
     _Reporter  = new Reporter(Writer);
     Rng        = new RNG();
     S          = new Stringer(350);
 }
예제 #17
0
        public async Task <ActionResult> DeleteConfirmed(Guid id)
        {
            Stringer stringer = await db.Stringers.FindAsync(id);

            db.Stringers.Remove(stringer);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
예제 #18
0
        // ----------------------------- Connect ---------------------------------
        // connect to the remote socket.
        public void Connect( )
        {
            mSocket = null;

            // make sure server name and port have been spcfd.
            if (Stringer.IsEmpty(mServerName) == true)
            {
                ThrowNetworkException("Connect error. Server name is empty.");
            }
            if (mServerPortNx == 0)
            {
                ThrowNetworkException("Connect error. Server port number is zero.");
            }

            // resolve and connect to the remote system.
            try
            {
                // resolve to the host server.
                IPHostEntry hostEntry = null;
                hostEntry = Dns.GetHostEntry(mServerName);

                // I guess Resolve returns a list of IP addresses. ( something to do with
                // IPv6 ). This loop is standard stuff pulled from the MS documenation.
                // Try to connect to each address until successful.
                foreach (IPAddress address in hostEntry.AddressList)
                {
                    IPEndPoint ep         = new IPEndPoint(address, mServerPortNx);
                    Socket     tempSocket = new Socket(
                        ep.AddressFamily,
                        SocketType.Stream,
                        ProtocolType.Tcp);

                    tempSocket.Connect(ep);

                    if (tempSocket.Connected == true)
                    {
                        ConnectedSocket = tempSocket;
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                ThrowNetworkException(
                    "Exception connecting to " + ServerPortCombo, e);
            }

            // throw exception if can't connect ...
            if (mSocket == null)
            {
                ThrowNetworkException("Failed to connect to " + ServerPortCombo);
            }
            else
            {
                AddMessage(NetworkRole.Client, "Connected to " + ServerPortCombo);
            }
        }
예제 #19
0
 public static bool _ <T>(this Stringer target, out T result)
 {
     try
     {
         result = target._ <T>();
         return(true);
     }
     catch (PanicException)
     {
         result = default !;
예제 #20
0
 public void AddToCompilerOptions(string InOptions)
 {
     if (Stringer.IsBlank(this.CompilerOptions) == true)
     {
         this.CompilerOptions = InOptions;
     }
     else
     {
         this.CompilerOptions = this.CompilerOptions + " " + InOptions;
     }
 }
예제 #21
0
 // ------------------------ ValidityCheck --------------------------
 public virtual void ValidityCheck(AcAccountMasterRow InRow)
 {
     if (Stringer.IsBlank(InRow.AccountName))
     {
         throw(new AccountMasterException("Account name is blank"));
     }
     if (Stringer.IsBlank(InRow.Password))
     {
         throw(new AccountMasterException("Password is missing"));
     }
 }
예제 #22
0
        private static int AverageLengthWord(string input)
        {
            int sum = 0;

            string[] partsInput = Stringer.GetArrayString(input);
            for (int i = 0; i < partsInput.Length; i++)
            {
                sum += partsInput[i].Length;
            }
            return(sum / partsInput.Length);
        }
예제 #23
0
 public static T _ <T>(this Stringer target)
 {
     try
     {
         return(((Stringer <T>)target).Target);
     }
     catch (NotImplementedException ex)
     {
         throw new PanicException($"interface conversion: {GetGoTypeName(target.GetType())} is not {GetGoTypeName(typeof(T))}: missing method {ex.InnerException?.Message}", ex);
     }
 }
예제 #24
0
 /// <summary>
 /// evaluate if this pattern matches the current location in the string.
 /// </summary>
 /// <param name="InString"></param>
 /// <param name="InBx"></param>
 /// <param name="InEx"></param>
 /// <param name="InIx"></param>
 /// <returns></returns>
 public bool Evaluate(string Text, int Bx, int Ex, int Ix)
 {
     if (mLeadChar == Text[Ix])
     {
         return(true);
     }
     else
     {
         bool rv = Stringer.CompareSubstringEqual(
             Text, Ix, Ex, this.PatternValue);
         return(rv);
     }
 }
예제 #25
0
    public void SetValue(List <string> inNames)
    {
        for (int i = 0; i < inNames.Count; i++)
        {
            string classname = Stringer.FirstLetterUp(inNames[i]);

            ItemField field = new ItemField("Dictionary<string," + classname + ">", classname + "Dic", "new " + "Dictionary<string," + classname + ">()");
            field.SetAttributes(MemberAttributes.Final | MemberAttributes.Public);
            field.AddAttributes("ProtoMember", i + 1);
            fieldList.Add(field);
        }
        // Create();
    }
예제 #26
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder(10000);

            sb.Append(Stringer.GetNonNull(mPanelClass));
            sb.Append(",");
            sb.Append(Stringer.GetNonNull(mTitleClass));
            sb.Append(",");
            sb.Append(Stringer.GetNonNull(mHeadingClass));
            sb.Append(",");
            sb.Append(Stringer.GetNonNull(mFieldClass));
            return(sb.ToString());
        }
예제 #27
0
        public static IpInfo GetIpGeoInfo(string InIpAddr)
        {
            IpInfo ipInfo = new IpInfo( );

            // get an arraylist containing all the ip info from GeoBytes.
            ArrayList ts = GetFullIpLocator(InIpAddr);

            // step thru the arraylist of ip info.
            IEnumerator it = ts.GetEnumerator( );

            while (it.MoveNext( ) == true)
            {
                // load the ip info stmt line.
                string IpInfoLine = (string)it.Current;
                if (IpInfoLine == null)
                {
                    continue;
                }
                IpInfoLine = Stringer.TrimStartAndEnd(
                    IpInfoLine,
                    Chars.WhitespaceChars( ),
                    Chars.WhitespaceChars(';'));
                TextStmt.TextStmt stmt = new TextStmt.TextStmt(IpInfoLine);

                // each stmt line is in assignment form. split the stmt into its lhs and
                // rhs parts.
                SplitResults lineParts = stmt.Split('=');
                if (lineParts.Length != 2)
                {
                    continue;
                }
                string lhs = lineParts.Content[0].Trim( );
                string rhs = lineParts.Content[1].Trim( );

                // depending on the lhs value name, store the rhs value.
                if (lhs == "country")
                {
                    ipInfo.Country = rhs;
                }
                else if (lhs == "region")
                {
                    ipInfo.Region = rhs;
                }
                else if (lhs == "city")
                {
                    ipInfo.City = rhs;
                }
            }
            return(ipInfo);
        }
예제 #28
0
        static void Main(string[] args)
        {
            Console.Write("Введите первую строку: ");
            string input1 = Console.ReadLine();

            Console.Write("Введите вторую строку: ");
            string input2 = Console.ReadLine();

            string[] partsInput1 = Stringer.GetArrayString(input1);
            string[] partsInput2 = Stringer.GetArrayString(input2);
            Console.Write("Результирующая строка:");
            Console.Write(ResultingString(partsInput1, partsInput2, input1).Trim());
            Console.ReadKey();
        }
예제 #29
0
        // -------------------------- ToSendString --------------------------------
        public string ToSendString( )
        {
            StringBuilder sb = new StringBuilder(512);

            if (FriendlyName != null)
            {
                sb.Append(
                    Stringer.Enquote(FriendlyName, '"', QuoteEncapsulation.Escape) +
                    " ");
            }
            sb.Append('<');
            sb.Append(Address);
            sb.Append('>');
            return(sb.ToString( ));
        }
예제 #30
0
        // ---------------- DecodeHeaderString_QuotedOnly --------------------------
        // decode the header string.  If it is quoted, dequote it. Otherwise, return as is.
        public static string DecodeHeaderString_QuotedOnly(string InString)
        {
            QuoteEncapsulation qem     = QuoteEncapsulation.Escape;
            string             results = null;

            if (Stringer.IsQuoted(InString, qem) == true)
            {
                results = Stringer.Dequote(InString, qem);
            }
            else
            {
                results = InString;
            }
            return(results);
        }
 public void BuildString(StringBuilder sb, Stringer elemstringer) 
 {
   if (this.tail != null) 
   {
     sb.AppendFormat("{0},", elemstringer(this.elem));
     this.tail.BuildString(sb, elemstringer);
   }
   else 
   {
     sb.Append(elemstringer(this.elem));
   }
 }
    public String ToString(Stringer elemstringer) 
    {
      StringBuilder sb = new StringBuilder();

      this.BuildString(sb, elemstringer);
      return sb.ToString();
    }
예제 #33
0
        static void Test()
        {
            //Calculate x+y
            var summ = new Summator();
            var summ2 = new Summator();
            var summ3 = new Summator();
            var str = new Stringer();

            var one = new InPoint(new IntColor(1));
            var one2 = new OutPoint(new IntColor(1));
            var two = new InPoint(new IntColor(2));
            var three = new OutPoint(new IntColor(3));
            var four = new OutPoint(new IntColor(5));
            var mix1 = new MixNode();

            one.ConnectTo(summ);
            two.ConnectTo(summ);

            one2.ConnectTo(summ).ConnectTo(summ2);
            three.ConnectTo(summ2).ConnectTo(str);

            four.ConnectTo(summ2);
            summ.ConnectTo(summ3);
            summ2.ConnectTo(summ3);
            summ3.ConnectTo(str);
            new OutPoint(new IntColor(6)).ConnectTo(str);
            //str.ConnectTo(mix1);
            // new OutPoint(new StringColor("abba")).ConnectTo(mix1);/**/
            // graph.Add(new ColorableClass[] { one, two, one2, three });
            graph.Add(new ConnectionPoint[] { one, two, one2, three, four });
            graph.OnFinish += OnFinish;
            graph.StartAsync();
        }