コード例 #1
0
ファイル: MoveToAs.cs プロジェクト: nathaliefil/uroboros
        protected override void FileAction(string fileName, string rawLocation)
        {
            string directoryName = destination.ToString();

            if (!FileValidator.IsNameCorrect(directoryName))
            {
                RuntimeVariables.GetInstance().Failure();
                throw new CommandException("Action ignored! " + directoryName + " contains not allowed characters.");
            }

            string newFileName = newName.ToString();

            if (!FileValidator.IsNameCorrect(newFileName))
            {
                RuntimeVariables.GetInstance().Failure();
                throw new CommandException("Action ignored! " + newFileName + " contains not allowed characters.");
            }
            if (FileValidator.IsDirectory(newFileName))
            {
                string extension = FileInnerVariable.GetExtension(fileName);
                newFileName += "." + extension;
            }

            string oldLocation = rawLocation + "//" + fileName;
            string newLocation = rawLocation + "//" + directoryName + "//" + newFileName;


            if (!Directory.Exists(rawLocation + "//" + directoryName))
            {
                Directory.CreateDirectory(rawLocation + "//" + directoryName);
            }


            try
            {
                if (forced && File.Exists(newLocation))
                {
                    File.Delete(@newLocation);
                }
                File.Move(@oldLocation, @newLocation);

                RuntimeVariables.GetInstance().Success();
                Logger.GetInstance().LogCommand("Move " + fileName + " to " + directoryName + " as " + newFileName);
            }
            catch (Exception ex)
            {
                RuntimeVariables.GetInstance().Failure();

                if (ex is IOException || ex is UnauthorizedAccessException)
                {
                    throw new CommandException("Action ignored! Access denied during moving " + fileName + " to " + directoryName + " as " + newFileName + ".");
                }
                else
                {
                    throw new CommandException("Action ignored! Something went wrong during moving " + fileName + " to " + directoryName + " as " + newFileName + ".");
                }
            }
        }
コード例 #2
0
        protected override void FileAction(string oldFileName, string rawLocation)
        {
            string newFileName = destination.ToString();

            if (!FileValidator.IsNameCorrect(newFileName))
            {
                RuntimeVariables.GetInstance().Failure();
                throw new CommandException("Action ignored! " + newFileName + " contains not allowed characters.");
            }

            if (FileValidator.IsDirectory(newFileName))
            {
                string extension = FileInnerVariable.GetExtension(oldFileName);
                newFileName += "." + extension;
            }

            if (oldFileName.Equals(newFileName))
            {
                RuntimeVariables.GetInstance().Failure();
                throw new CommandException("Action ignored! Old name and new name for " + newFileName + " are the same and renaming is unnecessary.");
            }


            string slocation = rawLocation + "//" + oldFileName;
            string nlocation = rawLocation + "//" + newFileName;

            try
            {
                if (forced && File.Exists(nlocation))
                {
                    File.Delete(@nlocation);
                }
                File.Move(@slocation, @nlocation);
                RuntimeVariables.GetInstance().Success();
                Logger.GetInstance().LogCommand("Rename " + oldFileName + " to " + newFileName);
            }
            catch (Exception ex)
            {
                RuntimeVariables.GetInstance().Failure();

                if (ex is IOException || ex is UnauthorizedAccessException)
                {
                    throw new CommandException("Action ignored! Access denied during renaming " + oldFileName + " to " + newFileName + ".");
                }
                else
                {
                    throw new CommandException("Action ignored! Something went wrong during renaming " + oldFileName + " to " + newFileName + ".");
                }
            }
        }
コード例 #3
0
ファイル: FuncFilled.cs プロジェクト: nathaliefil/uroboros
        public override string ToString()
        {
            string value;
            int    number = (int)arg1.ToNumber();

            if (arg0 is INumerable)
            {
                if ((arg0 as INumerable).ToNumber() % 1 == 0)
                {
                    value = ((int)(arg0 as INumerable).ToNumber()).ToString();
                }
                else
                {
                    value = (arg0 as INumerable).ToNumber().ToString();
                }
            }
            else
            {
                value = arg0.ToString();
            }

            if (value.Length >= number)
            {
                return(value);
            }

            return(string.Concat(Enumerable.Repeat("0", number - value.Length)) + value);
        }
コード例 #4
0
        public override string ToString()
        {
            string source = arg0.ToString();

            int arg1v = (int)arg1.ToNumber();

            if (arg1v >= source.Length)
            {
                return("");
            }

            int arg2v = (int)arg2.ToNumber();

            if (arg2v < 1)
            {
                return("");
            }

            if (arg1v + arg2v > source.Length)
            {
                arg2v -= arg1v + arg2v - source.Length;
            }

            return(source.Substring(arg1v, arg2v));
        }
コード例 #5
0
ファイル: SmallArrow.cs プロジェクト: nathaliefil/uroboros
        public override List <string> ToList()
        {
            List <string> result   = new List <string>();
            decimal       oldIndex = RuntimeVariables.GetInstance().GetValueNumber("index");
            string        oldThis  = RuntimeVariables.GetInstance().GetValueString("this");

            RuntimeVariables.GetInstance().Actualize("index", 0);

            foreach (string element in leftSide.ToList())
            {
                RuntimeVariables.GetInstance().Actualize("this", element);

                string value = rightSide.ToString();
                if (unique)
                {
                    if (!result.Contains(value))
                    {
                        result.Add(value);
                    }
                }
                else
                {
                    result.Add(value);
                }

                RuntimeVariables.GetInstance().PlusPlus("index");
            }

            RuntimeVariables.GetInstance().Actualize("index", oldIndex);
            RuntimeVariables.GetInstance().Actualize("this", oldThis);
            return(result);
        }
コード例 #6
0
        public override bool ToBool()
        {
            string leftValue  = leftSide.ToString();
            string rightValue = rightSide.ToString();

            switch (type)
            {
            case ComparisonType.Equals:
                return(leftValue.Equals(rightValue) ? true : false);

            case ComparisonType.NotEquals:
                return(leftValue.Equals(rightValue) ? false : true);

            case ComparisonType.Bigger:
                return(leftValue.CompareTo(rightValue) == 1 ? true : false);

            case ComparisonType.Smaller:
                return(leftValue.CompareTo(rightValue) == -1 ? true : false);

            case ComparisonType.BiggerOrEquals:
                return(leftValue.CompareTo(rightValue) > -1 ? true : false);

            case ComparisonType.SmallerOrEquals:
                return(leftValue.CompareTo(rightValue) < 1 ? true : false);
            }

            return(false);
        }
コード例 #7
0
ファイル: FuncYear.cs プロジェクト: nathaliefil/uroboros
        public override decimal ToNumber()
        {
            StringBuilder stringb = new StringBuilder();

            foreach (char ch in arg0.ToString())
            {
                if (Char.IsDigit(ch))
                {
                    stringb.Append(ch);
                }
                else
                {
                    if (stringb.Length == 4)
                    {
                        return(Decimal.Parse(stringb.ToString()));
                    }
                    else
                    {
                        if (stringb.Length > 0)
                        {
                            stringb.Clear();
                        }
                    }
                }
            }

            if (stringb.Length == 4)
            {
                return(Decimal.Parse(stringb.ToString()));
            }
            else
            {
                return(0);
            }
        }
コード例 #8
0
        // Token: 0x060063D6 RID: 25558 RVA: 0x001531CC File Offset: 0x001513CC
        internal static string ToString(object obj)
        {
            IStringable stringable = obj as IStringable;

            if (stringable != null)
            {
                return(stringable.ToString());
            }
            return(obj.ToString());
        }
コード例 #9
0
 public override string ToString()
 {
     if (AppDomain.IsAppXModel())
     {
         IStringable stringable = this as IStringable;
         if (stringable != null)
         {
             return(stringable.ToString());
         }
     }
     return(base.ToString());
 }
コード例 #10
0
        public override bool ToBool()
        {
            string file      = arg0.ToString();
            string directory = arg1.ToString();

            if (file.Equals("") || directory.Equals(""))
            {
                return(false);
            }

            return(FileInnerVariable.ExistInside(file, directory));
        }
コード例 #11
0
        public override string ToString()
        {
            string source = arg0.ToString();
            int    arg1v  = (int)arg1.ToNumber();

            if (arg1v >= source.Length)
            {
                return(base.ToString());
            }

            return(source.Substring(arg1v));
        }
コード例 #12
0
 public override decimal ToNumber()
 {
     try
     {
         decimal value = Decimal.Parse(arg0.ToString());
         return(value);
     }
     catch (Exception)
     {
         return(0);
     }
 }
コード例 #13
0
ファイル: RuntimeClass.cs プロジェクト: alisci01/cs2cpp
        internal static string ToString(object obj)
        {
            // Check whether the type implements IStringable.
            IStringable stringableType = obj as IStringable;

            if (stringableType != null)
            {
                return(stringableType.ToString());
            }

            return(obj.ToString());
        }
コード例 #14
0
ファイル: FuncRepeat.cs プロジェクト: nathaliefil/uroboros
        public override string ToString()
        {
            int repeats = (int)arg1.ToNumber();

            if (repeats <= 0)
            {
                return("");
            }
            else
            {
                return(string.Concat(Enumerable.Repeat(arg0.ToString(), repeats)));
            }
        }
コード例 #15
0
ファイル: FuncLetters.cs プロジェクト: nathaliefil/uroboros
        public override string ToString()
        {
            string value = arg0.ToString();

            if (string.IsNullOrEmpty(value))
            {
                return(value);
            }
            else
            {
                return(new string(value.Where(char.IsLetter).ToArray()));
            }
        }
コード例 #16
0
        public override string ToString()
        {
            string text   = arg0.ToString();
            string phrase = arg1.ToString();

            int index = text.IndexOf(phrase);

            if (index <= 0)
            {
                return("");
            }

            return(text.Substring(0, index));
        }
コード例 #17
0
        public override string ToString()
        {
            IStringable stringable = this as IStringable;

            if (stringable != null)
            {
                return(stringable.ToString());
            }
            IntPtr redirectedToStringMd = this.GetRedirectedToStringMD();

            if (redirectedToStringMd == IntPtr.Zero)
            {
                return(base.ToString());
            }
            return(this.RedirectToString(redirectedToStringMd));
        }
コード例 #18
0
ファイル: __ComObject.cs プロジェクト: spresec/coreclr
        //====================================================================
        // Overrides ToString() to make sure we call to IStringable if the
        // COM object implements it in the case of weakly typed RCWs
        //====================================================================
        public override string ToString()
        {
            //
            // Only do the IStringable cast when running under AppX for better compat
            // Otherwise we could do a IStringable cast in classic apps which could introduce
            // a thread transition which would lead to deadlock
            //
            if (AppDomain.IsAppXModel())
            {
                // Check whether the type implements IStringable.
                IStringable stringableType = this as IStringable;
                if (stringableType != null)
                {
                    return(stringableType.ToString());
                }
            }

            return(base.ToString());
        }
コード例 #19
0
ファイル: RuntimeClass.cs プロジェクト: yukozh/coreclr
        internal static string ToString(object obj)
        {
            IGetProxyTarget proxy = obj as IGetProxyTarget;

            if (proxy != null)
            {
                obj = proxy.GetTarget();
            }

            // Check whether the type implements IStringable.
            IStringable stringableType = obj as IStringable;

            if (stringableType != null)
            {
                return(stringableType.ToString());
            }

            return(obj.ToString());
        }
コード例 #20
0
ファイル: RuntimeClass.cs プロジェクト: alisci01/cs2cpp
        public override string ToString()
        {
            // Check whether the type implements IStringable.
            IStringable stringableType = this as IStringable;

            if (stringableType != null)
            {
                return(stringableType.ToString());
            }
            else
            {
                IntPtr pMD = GetRedirectedToStringMD();

                if (pMD == IntPtr.Zero)
                {
                    return(base.ToString());
                }

                return(RedirectToString(pMD));
            }
        }
コード例 #21
0
        public override decimal ToNumber()
        {
            string d = directory.ToString();

            if (d.Trim().Equals(""))
            {
                return(0);
            }

            RuntimeVariables.GetInstance().ExpandLocation(d);

            if (!RuntimeVariables.GetInstance().WholeLocationExists())
            {
                RuntimeVariables.GetInstance().RetreatLocation();
                return(0);
            }

            decimal count = list.ToList().Count;

            RuntimeVariables.GetInstance().RetreatLocation();
            return(count);
        }
コード例 #22
0
        protected override void FileAction(string fileName, string newLocation)
        {
            string source         = from.ToString();
            string sourceLocation = RuntimeVariables.GetInstance().GetValueString("location") + "//" + source;

            if (!FileValidator.IsNameCorrect(source))
            {
                RuntimeVariables.GetInstance().Failure();
                throw new CommandException("Action ignored! Source file name in creation of file " + fileName + " contains not allowed characters.");
            }

            if (!File.Exists(sourceLocation))
            {
                RuntimeVariables.GetInstance().Failure();
                throw new CommandException("Action ignored! Source file " + source + " do not exist.");
            }


            try
            {
                File.Copy(@sourceLocation, @newLocation);
                RuntimeVariables.GetInstance().Success();
                Logger.GetInstance().LogCommand("Create file " + fileName);
            }
            catch (Exception ex)
            {
                RuntimeVariables.GetInstance().Failure();

                if (ex is IOException || ex is UnauthorizedAccessException)
                {
                    throw new CommandException("Action ignored! Access denied during creating file " + fileName + ".");
                }
                else
                {
                    throw new CommandException("Action ignored! Something went wrong during creating file " + fileName + ".");
                }
            }
        }
コード例 #23
0
ファイル: FuncIndexof.cs プロジェクト: nathaliefil/uroboros
 public override decimal ToNumber()
 {
     return(arg0.ToString().IndexOf(arg1.ToString()));
 }
コード例 #24
0
ファイル: FuncFullname.cs プロジェクト: nathaliefil/uroboros
        public override string ToString()
        {
            string file = arg0.ToString();

            return(FileInnerVariable.GetFullname(file));
        }
コード例 #25
0
        public override DateTime ToTime()
        {
            string file = arg0.ToString();

            return(FileInnerVariable.GetModification(file));
        }
コード例 #26
0
 public void Run()
 {
     RuntimeVariables.GetInstance().Remove(name, value.ToString());
 }
コード例 #27
0
ファイル: FuncExist.cs プロジェクト: nathaliefil/uroboros
        public override bool ToBool()
        {
            string file = arg0.ToString();

            return(FileInnerVariable.Exist(file));
        }
コード例 #28
0
 public override bool ToBool()
 {
     return(compared.ToList().Any(e => e.ToString().Equals(value.ToString())));
 }
コード例 #29
0
ファイル: FuncSize.cs プロジェクト: nathaliefil/uroboros
        public override decimal ToNumber()
        {
            string file = arg0.ToString();

            return(FileInnerVariable.GetSize(file));
        }
コード例 #30
0
 public override string ToString()
 {
     return(condition.ToBool() ? leftValue.ToString() : rightValue.ToString());
 }