Beispiel #1
0
        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 + ".");
                }
            }
        }
Beispiel #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 + ".");
                }
            }
        }
Beispiel #3
0
        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);
        }
        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));
        }
Beispiel #5
0
        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);
        }
        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);
        }
Beispiel #7
0
        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);
            }
        }
        // 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());
        }
Beispiel #9
0
 public override string ToString()
 {
     if (AppDomain.IsAppXModel())
     {
         IStringable stringable = this as IStringable;
         if (stringable != null)
         {
             return(stringable.ToString());
         }
     }
     return(base.ToString());
 }
Beispiel #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));
        }
Beispiel #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));
        }
Beispiel #12
0
 public override decimal ToNumber()
 {
     try
     {
         decimal value = Decimal.Parse(arg0.ToString());
         return(value);
     }
     catch (Exception)
     {
         return(0);
     }
 }
Beispiel #13
0
        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());
        }
Beispiel #14
0
        public override string ToString()
        {
            int repeats = (int)arg1.ToNumber();

            if (repeats <= 0)
            {
                return("");
            }
            else
            {
                return(string.Concat(Enumerable.Repeat(arg0.ToString(), repeats)));
            }
        }
Beispiel #15
0
        public override string ToString()
        {
            string value = arg0.ToString();

            if (string.IsNullOrEmpty(value))
            {
                return(value);
            }
            else
            {
                return(new string(value.Where(char.IsLetter).ToArray()));
            }
        }
Beispiel #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));
        }
Beispiel #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));
        }
Beispiel #18
0
        //====================================================================
        // 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());
        }
Beispiel #19
0
        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());
        }
Beispiel #20
0
        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));
            }
        }
Beispiel #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);
        }
Beispiel #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 + ".");
                }
            }
        }
Beispiel #23
0
 public override decimal ToNumber()
 {
     return(arg0.ToString().IndexOf(arg1.ToString()));
 }
Beispiel #24
0
        public override string ToString()
        {
            string file = arg0.ToString();

            return(FileInnerVariable.GetFullname(file));
        }
        public override DateTime ToTime()
        {
            string file = arg0.ToString();

            return(FileInnerVariable.GetModification(file));
        }
Beispiel #26
0
 public void Run()
 {
     RuntimeVariables.GetInstance().Remove(name, value.ToString());
 }
Beispiel #27
0
        public override bool ToBool()
        {
            string file = arg0.ToString();

            return(FileInnerVariable.Exist(file));
        }
Beispiel #28
0
 public override bool ToBool()
 {
     return(compared.ToList().Any(e => e.ToString().Equals(value.ToString())));
 }
Beispiel #29
0
        public override decimal ToNumber()
        {
            string file = arg0.ToString();

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