public Form1(ILogger logger, ICopy copy, int valueToEdit)
 {
     this._processRepository = logger;
     this._copy       = copy;
     this.ValueToEdit = valueToEdit;
     InitializeComponent();
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="OperationSubCopy{TSource,TTarget, TSubCopy}" /> class.
        /// </summary>
        public OperationSubCopy(
            ICopy <TValue> copy)
        {
            copy.NotNull(nameof(copy));

            this.copy = copy;
        }
Exemple #3
0
        /// <summary>
        /// Copies to.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="progressDelegate">The progress delegate.</param>
        /// <remarks>Documented by Dev03, 2009-01-13</remarks>
        public void CopyTo(ICopy target, CopyToProgress progressDelegate)
        {
            CopyBase.Copy(this, target, typeof(ICard), progressDelegate);

            //copy media objects
            ICard targetCard = target as ICard;

            if (targetCard != null)
            {
                foreach (IMedia media in QuestionMedia)
                {
                    targetCard.AddMedia(media, Side.Question);
                }
                foreach (IMedia media in AnswerMedia)
                {
                    targetCard.AddMedia(media, Side.Answer);
                }
                try
                {
                    if (targetCard is MLifter.DAL.XML.XmlCard)
                    {
                        (targetCard as MLifter.DAL.XML.XmlCard).Id = Id;
                    }
                }
                catch (Exception ex)
                {
                    Trace.WriteLine("Tried to set the card id for XML but failed: " + ex.ToString());
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// 将对象转化为json格式字符串
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static T CopyTo <T>(this ICopy obj) where T : new()
        {
            if (obj == null)
            {
                return(default(T));
            }
            var result = new T();

            var sourceProps = obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
            var targetProps = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);

            foreach (var tp in targetProps)
            {
                if (!tp.CanWrite)
                {
                    continue;
                }

                foreach (var sp in sourceProps)
                {
                    if (!string.Equals(tp.Name, sp.Name, StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }
                    tp.SetValue(result, sp.GetValue(obj));
                    break;
                }
            }
            return(result);
        }
        private void Copy()
        {
            Request R = new Request();
            Request R2;

            R2 = ICopy.Clone <Request>(R); /*  ICopy.Clone<Request>(   */
        }
 public void CopyValue(ICopy copyTo)
 {
     if (copyTo.IsList)
     {
         var l = copyTo as PList <T>;
         if (mIsSet)
         {
             l.Add(mValue);
         }
         else
         {
             l.Remove(mValue);
         }
     }
     else
     {
         var p = copyTo as PValue <T>;
         if (p == null)
         {
             return;
         }
         p.mValue = mValue;
         p.mIsSet = mIsSet;
     }
 }
Exemple #7
0
        /// <summary>
        /// Copies the specified source.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="target">The target.</param>
        /// <param name="type">The type the source and target should be interpreded as.</param>
        /// <param name="progressDelegate">The progress delegate.</param>
        public static void Copy(ICopy source, ICopy target, Type type, CopyToProgress progressDelegate)
        {
            if (!(type.IsAssignableFrom(source.GetType()) && type.IsAssignableFrom(target.GetType())))
            {
                throw new ArgumentException("Source and Target must implement " + type.ToString());
            }

            foreach (PropertyInfo info in type.GetProperties())
            {
                if (type.GetProperty(info.Name).IsDefined(typeof(IgnoreCopyAttribute), true) ||
                    source.GetType().GetProperty(info.Name).IsDefined(typeof(IgnoreCopyAttribute), true) ||
                    target.GetType().GetProperty(info.Name).IsDefined(typeof(IgnoreCopyAttribute), true))
                {
                    continue;
                }

                if (typeof(ICopy).IsAssignableFrom(info.PropertyType))
                {
                    ICopy copyObject = (info.GetValue(source, null) as ICopy);
                    if (copyObject != null)
                    {
                        copyObject.CopyTo(info.GetValue(target, null) as ICopy, progressDelegate);
                    }
                }

                if (info.IsDefined(typeof(ValueCopyAttribute), true))
                {
                    object value = info.GetValue(source, null);
                    if (value != null)
                    {
                        info.SetValue(target, value, null);
                    }
                }
            }
        }
        public CopyOperationPostProcessingUsingParamsIntTests()
        {
            var container = TestIocContainer.Initialize();

            container.Bind <ICopyRegistrations <ITestClass> >().To <TestClassCopyRegistrations>();
            this.copy = container.Get <ICopy <ITestClass> >();
        }
Exemple #9
0
        /// <summary>
        /// Copies the specified source.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="target">The target.</param>
        /// <param name="progressDelegate">The progress delegate.</param>
        /// <remarks>Documented by Dev05, 2012-01-11</remarks>
        public static void Copy(ICopy source, ICopy target, CopyToProgress progressDelegate)
        {
            if (source.GetType() != target.GetType())
                throw new ArgumentException("Source and Target must be the same type!");

            Copy(source, target, source.GetType(), progressDelegate);
        }
Exemple #10
0
        /// <summary>
        /// Copies the specified source.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="target">The target.</param>
        /// <param name="type">The type the source and target should be interpreded as.</param>
        /// <param name="progressDelegate">The progress delegate.</param>
        public static void Copy(ICopy source, ICopy target, Type type, CopyToProgress progressDelegate)
        {
            if (!(type.IsAssignableFrom(source.GetType()) && type.IsAssignableFrom(target.GetType())))
                throw new ArgumentException("Source and Target must implement " + type.ToString());

            foreach (PropertyInfo info in type.GetProperties())
            {
                if (type.GetProperty(info.Name).IsDefined(typeof(IgnoreCopyAttribute), true) ||
                    source.GetType().GetProperty(info.Name).IsDefined(typeof(IgnoreCopyAttribute), true) ||
                    target.GetType().GetProperty(info.Name).IsDefined(typeof(IgnoreCopyAttribute), true))
                    continue;

                if (typeof(ICopy).IsAssignableFrom(info.PropertyType))
                {
                    ICopy copyObject = (info.GetValue(source, null) as ICopy);
                    if (copyObject != null)
                        copyObject.CopyTo(info.GetValue(target, null) as ICopy, progressDelegate);
                }

                if (info.IsDefined(typeof(ValueCopyAttribute), true))
                {
                    object value = info.GetValue(source, null);
                    if (value != null)
                        info.SetValue(target, value, null);
                }
            }
        }
        public CopyOperationPostProcessingWithoutUsingParamsIntTest()
        {
            var kernel = TestIocContainer.Initialize();

            kernel.Bind <ICopyRegistrations <ITestClass> >().To <TestClassCopyRegistrations>();

            this.testCandidate = kernel.Get <ICopy <ITestClass> >();
        }
        public CopyOperationInlineValueProcessingTests()
        {
            var kernel = TestIocContainer.Initialize();

            kernel.Bind <ICopyRegistrations <TestClass> >().To <TestClassCopyRegistrations>();

            this.testCandidate = kernel.Get <ICopy <TestClass> >();
        }
        public CopyOperationSubCopyIntTests()
        {
            var kernel = TestIocContainer.Initialize();

            kernel.Bind <ICopyRegistrations <TestClassChild> >().To <TestClassChildCopyRegistrations>();
            kernel.Bind <ICopyRegistrations <TestClassParent> >().To <TestClassParentCopyRegistrations>();

            this.testCandidate = kernel.Get <ICopy <TestClassChild> >();
        }
        public CopyOperationCreateToManyWithReverseRelationIntTests()
        {
            var kernel = TestIocContainer.Initialize();

            kernel.Bind <ICopyRegistrations <IParentTestClass> >().To <TestClassCopyRegistrations>();
            kernel.Bind <ICopyRegistrations <IChildTestClass> >().To <ChildTestClassCopyRegistrations>();

            this.testCandidate = kernel.Get <ICopy <IParentTestClass> >();
        }
Exemple #15
0
        /// <summary>
        /// Copies the specified source.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="target">The target.</param>
        /// <param name="progressDelegate">The progress delegate.</param>
        /// <remarks>Documented by Dev05, 2012-01-11</remarks>
        public static void Copy(ICopy source, ICopy target, CopyToProgress progressDelegate)
        {
            if (source.GetType() != target.GetType())
            {
                throw new ArgumentException("Source and Target must be the same type!");
            }

            Copy(source, target, source.GetType(), progressDelegate);
        }
Exemple #16
0
        public CopyOperationRegisterCreateFromFactoryTests()
        {
            var kernel = TestIocContainer.Initialize();

            kernel.Bind <ICopyRegistrations <TestClass> >().To <TestClassCopyRegistrations>();
            kernel.Bind <ITestFactory>().To <TestFactory>();

            this.testCandidate = kernel.Get <ICopy <TestClass> >();
        }
        /// <summary>
        /// Copies to.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="progressDelegate">The progress delegate.</param>
        /// <remarks>Documented by Dev03, 2009-01-13</remarks>
        public void CopyTo(ICopy target, CopyToProgress progressDelegate)
        {
            IChapters targetChapters = target as IChapters;

            if (targetChapters != null)
            {
                ChaptersHelper.Copy(this, targetChapters, progressDelegate);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GenericCopyStrategy{TBase, TDerived, TConcrete}"/> class.
        /// </summary>
        public GenericCopyStrategy(
            IInstanceCreator <TDerived, TConcrete> creator,
            ICopy <TDerived> copier)
        {
            creator.NotNull(nameof(creator));
            copier.NotNull(nameof(copier));

            this.creator = creator;
            this.copier  = copier;
        }
Exemple #19
0
        public CopierIntegrationTests()
        {
            var kernel = TestIocContainer.Initialize();

            kernel.Bind <ICopyRegistrations <IParentTestClass> >().To <TestClassCopyRegistrations>();
            kernel.Bind <ICopyRegistrations <IChildTestClass> >().To <ChildTestClassCopyRegistrations>();
            kernel.Bind <ICopyRegistrations <IChildTestClass2> >().To <ChildTestClass2CopyRegistrations>();

            this.testCandidate = kernel.Get <ICopy <IParentTestClass> >();
        }
        public CopyOperationCrossReferenceProcessingIntTests()
        {
            var kernel = TestIocContainer.Initialize();

            kernel.Bind <ICopyRegistrations <TestClass> >().To <TestClassCopyRegistrations>();
            kernel.Bind <ICopyRegistrations <TestClassChild> >().To <TestClassChildCopyRegistrations>();
            kernel.Bind <ICopyRegistrations <TestClassCrossReferencedChild> >().To <TestClassCrossReferencedChildCopyRegistrations>();

            this.testCandidate = kernel.Get <ICopy <TestClass> >();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CreateCopyHelper{TChild,TConcreteChild,TParent}"/> class.
        /// </summary>
        public CreateCopyHelper(
            IInstanceCreator <TChild, TConcreteChild> instanceCreator,
            ICopy <TChild> copy)
        {
            instanceCreator.NotNull(nameof(instanceCreator));
            copy.NotNull(nameof(copy));

            this.instanceCreator = instanceCreator;
            this.copy            = copy;
        }
 public PostXMLStoreOrderListUseCase(
     DrugstoreDbContext context,
     ILogger <PostXMLStoreOrderListUseCase> logger,
     ISerializer <MemoryStream, XmlMedicineSupplyModel> serializer,
     ICopy fileCopy)
 {
     this.context    = context;
     this.logger     = logger;
     this.serializer = serializer;
     this.fileCopy   = fileCopy;
 }
 public UploadSoldMedicinesListUseCase(
     DrugstoreDbContext context,
     ILogger <UploadSoldMedicinesListUseCase> logger,
     ISerializer <MemoryStream, XmlMedicineSupplyModel> serializer,
     ICopy fileCopy)
 {
     this.context    = context;
     this.logger     = logger;
     this.serializer = serializer;
     this.fileCopy   = fileCopy;
 }
Exemple #24
0
        public CopyOperationCreateToManyFromGenericStrategyWithReverseRelationIntTests()
        {
            var kernel = TestIocContainer.Initialize();

            kernel.Bind <IGenericStrategyProvider <TestStrategy, IChildTestClass> >().To <TestFactory>();
            kernel.Bind <ITestStrategy>().To <TestStrategy>();
            kernel.Bind <ICopyRegistrations <IParentTestClass> >().To <TestClassCopyRegistrations>();
            kernel.Bind <ICopyRegistrations <IChildTestClass> >().To <ChildTestClassCopyRegistrations>();

            this.testCandidate = kernel.Get <ICopy <IParentTestClass> >();
        }
Exemple #25
0
        /// <summary>
        /// Copies to.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="progressDelegate">The progress delegate.</param>
        /// <remarks>Documented by Dev03, 2009-01-13</remarks>
        public void CopyTo(ICopy target, CopyToProgress progressDelegate)
        {
            CopyBase.Copy(this, target, typeof(IDictionary), progressDelegate);

            //copy extensions
            foreach (IExtension extension in Extensions)
            {
                IExtension newExtension = ((IDictionary)target).ExtensionFactory(extension.Id);
                extension.CopyTo(newExtension, progressDelegate);
            }
        }
Exemple #26
0
        public MultiCopyFunctional(IPrint print, IScan scan, ICopy copy)
        {
            print = print ?? throw new ArgumentNullException(nameof(print));
            scan  = scan ?? throw new ArgumentNullException(nameof(scan));
            copy  = copy ?? throw new ArgumentNullException(nameof(copy));


            this.print = print;
            this.scan  = scan;
            this.copy  = copy;
        }
        /// <summary>
        /// Copies to.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="progressDelegate">The progress delegate.</param>
        /// <remarks>Documented by Dev03, 2009-01-13</remarks>
        public void CopyTo(ICopy target, CopyToProgress progressDelegate)
        {
            IChapter targetChapter = target as IChapter;

            if (targetChapter != null && targetChapter.Settings == null && this.Settings != null)
            {
                targetChapter.Settings = targetChapter.Parent.GetParentDictionary().CreateSettings();
            }

            CopyBase.Copy(this, target, typeof(IChapter), progressDelegate);
        }
 /// <summary>
 /// Copies to.
 /// </summary>
 /// <param name="target">The target.</param>
 /// <param name="progressDelegate">The progress delegate.</param>
 /// <remarks>Documented by Dev03, 2009-01-13</remarks>
 public void CopyTo(ICopy target, CopyToProgress progressDelegate)
 {
     CopyBase.Copy(this, target, typeof(ICardStyle), progressDelegate);
     if (target is DbCardStyle)
     {
         CopyMediaTo((DbCardStyle)target);
     }
     if (target is DbCardStyle)
     {
         ((DbCardStyle)target).FlushToDB();
     }
 }
Exemple #29
0
 public SuperMegaPrinterMachine(
     IPrinter printer,
     IScan scanner,
     IStaple stapler,
     IFax fax,
     ICopy copier)
 {
     _printer = printer;
     _scanner = scanner;
     _stapler = stapler;
     _fax     = fax;
     _copier  = copier;
 }
Exemple #30
0
 public SuperMegaPrinterMachine(
     IPrinter printer,
     IScan scanner,
     IStaple stapler,
     IFax fax,
     ICopy copier)
 {
     _printer = printer;
     _scanner = scanner;
     _stapler = stapler;
     _fax = fax;
     _copier = copier;
 }
            public void CopyValue(ICopy copyTo)
            {
                if (Count == 0)
                {
                    return;
                }
                var p = copyTo as PList <T>;

                if (p != null)
                {
                    p.AddRange(this);
                }
            }
Exemple #32
0
        private void ReplaceSelectedZone(IZone ReplaceZone, ICopy CopyParams)
        {
            IZone zone = worldmap.GetSelectedZone();

            if (zone == null)
            {
                return;
            }

            if (ReplaceZone != null)
            {
                worldmap.ReplaceSelectedZone(ReplaceZone, CopyParams);
            }
        }
Exemple #33
0
        public ICopy Get( ICopy other )
        {
            ICopy copy;
            if( !m_Map.TryGetValue( other.Id, out copy ) )
            {
                copy		= other.New();
                other.Id	= m_Map.Count + 1;

                m_Map[ other.Id ]	= copy;

                copy.Copy( this, other );
            }

            return copy;
        }
Exemple #34
0
        public ICopy Get(ICopy other)
        {
            ICopy copy;

            if (!m_Map.TryGetValue(other.Id, out copy))
            {
                copy     = other.New();
                other.Id = m_Map.Count + 1;

                m_Map[other.Id] = copy;

                copy.Copy(this, other);
            }

            return(copy);
        }
        private void btnOk_Click(object sender, EventArgs e)
        {
            SetControls(false);

            Copy CopyObj = new Copy();
            CopyObj.CopyChance = chkChance.Checked;
            CopyObj.CopyTerrain = chkTerrain.Checked;
            CopyObj.CopyDifficulty = chkDifficulty.Checked;
            CopyObj.CopyGroups = chkGroups.Checked;
            CopyObj.CopyLocations = chkLocations.Checked;
            CopyObj.CopyFlags = chkFlags.Checked;
            CopyObj.Overwrite = chkOverwrite.Checked;

            ICopyObj = CopyObj;

            this.Close();
        }
Exemple #36
0
        /// <summary>
        /// Copies to.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="progressDelegate">The progress delegate.</param>
        /// <remarks>Documented by Dev03, 2009-01-13</remarks>
        public void CopyTo(ICopy target, CopyToProgress progressDelegate)
        {
            IChapter targetChapter = target as IChapter;
            if (targetChapter != null && targetChapter.Settings == null && this.Settings != null)
                targetChapter.Settings = targetChapter.Parent.GetParentDictionary().CreateSettings();

            CopyBase.Copy(this, target, typeof(IChapter), progressDelegate);
        }
Exemple #37
0
 /// <summary>
 /// Copies to.
 /// </summary>
 /// <param name="target">The target.</param>
 /// <param name="progressDelegate">The progress delegate.</param>
 /// <remarks>Documented by Dev03, 2009-01-13</remarks>
 public void CopyTo(ICopy target, CopyToProgress progressDelegate)
 {
     CopyBase.Copy(this, target, typeof(ICardStyle), progressDelegate);
     if (target is DbCardStyle) CopyMediaTo((DbCardStyle)target);
     if (target is DbCardStyle) ((DbCardStyle)target).FlushToDB();
 }
Exemple #38
0
 public void CopyTo(ICopy target, CopyToProgress progressDelegate)
 {
     WordsHelper.CopyWords(this, target as IWords);
 }
Exemple #39
0
 /// <summary>
 /// Copies this instance to the specified target.
 /// </summary>
 /// <param name="target">The target.</param>
 /// <param name="progressDelegate">The progress delegate.</param>
 public void CopyTo(ICopy target, CopyToProgress progressDelegate)
 {
     CopyBase.Copy(this, target, typeof(ICardStyle), progressDelegate);
     if (target is MLifter.DAL.DB.DbCardStyle)
     {
         string basePath = Path.GetDirectoryName(this.Parent.GetParentDictionary().Connection);
         ITextStyle[] styles = { (target as MLifter.DAL.DB.DbCardStyle).Question, (target as MLifter.DAL.DB.DbCardStyle).QuestionExample, (target as MLifter.DAL.DB.DbCardStyle).Answer, (target as MLifter.DAL.DB.DbCardStyle).AnswerExample, (target as MLifter.DAL.DB.DbCardStyle).AnswerCorrect, (target as MLifter.DAL.DB.DbCardStyle).AnswerWrong };
         foreach (ITextStyle style in styles)
         {
             string[] keys = new String[style.OtherElements.Keys.Count];
             style.OtherElements.Keys.CopyTo(keys, 0);
             foreach (string key in keys)
             {
                 String value = style.OtherElements[key];
                 Match urlValue = m_ResourceFinder.Match(value);
                 Match m = m_ResourceFinder.Match(value);
                 if (m.Success)
                 {
                     string url = m.Groups["url"].Value.Trim(new char[] { '"', '\'' });
                     Uri uri;
                     Match extractId = m_extractSingleMediaId.Match(url);
                     if (!extractId.Success)
                     {
                         if (Uri.IsWellFormedUriString(url, UriKind.Absolute))
                         {
                             uri = new Uri(url);
                         }
                         else
                         {
                             uri = new Uri(new Uri(basePath + "/"), url);
                         }
                         style.OtherElements[key] = style.OtherElements[key].Replace(url, uri.AbsoluteUri);
                     }
                 }
             }
         }
         (target as MLifter.DAL.DB.DbCardStyle).FlushToDB();
     }
 }
Exemple #40
0
        /// <summary>
        /// Copies this instance to the specified target.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="progressDelegate">The progress delegate.</param>
        public void CopyTo(ICopy target, CopyToProgress progressDelegate)
        {
            CopyBase.Copy(this, target, typeof(IExtension), progressDelegate);

            //copy data stream
            using (Stream data = this.Data)
            {
                if (data != null)
                    ((IExtension)target).Data = data;
            }

            //copy actions
            IList<ExtensionAction> actions = ((IExtension)target).Actions;
            actions.Clear();
            foreach (ExtensionAction action in this.Actions)
                actions.Add(action);
        }
 /// <summary>
 /// Copies to.
 /// </summary>
 /// <param name="target">The target.</param>
 /// <param name="progressDelegate">The progress delegate.</param>
 /// <remarks>Documented by Dev03, 2008-12-03</remarks>
 public void CopyTo(ICopy target, CopyToProgress progressDelegate)
 {
     CopyBase.Copy(this, target, typeof(IDictionary), progressDelegate);
 }
Exemple #42
0
        /// <summary>
        /// Copies to.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="progressDelegate">The progress delegate.</param>
        /// <remarks>Documented by Dev03, 2009-01-13</remarks>
        public void CopyTo(ICopy target, CopyToProgress progressDelegate)
        {
            CopyBase.Copy(this, target, typeof(ICard), progressDelegate);

            //copy media objects
            ICard targetCard = target as ICard;
            if (targetCard != null)
            {
                foreach (IMedia media in QuestionMedia)
                    targetCard.AddMedia(media, Side.Question);
                foreach (IMedia media in AnswerMedia)
                    targetCard.AddMedia(media, Side.Answer);
                try
                {
                    if (targetCard is MLifter.DAL.XML.XmlCard)
                        (targetCard as MLifter.DAL.XML.XmlCard).Id = Id;
                }
                catch (Exception ex)
                {
                    Trace.WriteLine("Tried to set the card id for XML but failed: " + ex.ToString());
                }
            }
        }
Exemple #43
0
 /// <summary>
 /// Copies to.
 /// </summary>
 /// <param name="target">The target.</param>
 /// <param name="progressDelegate">The progress delegate.</param>
 /// <remarks>Documented by Dev03, 2009-01-13</remarks>
 public void CopyTo(ICopy target, CopyToProgress progressDelegate)
 {
     IChapters targetChapters = target as IChapters;
     if (targetChapters != null)
         ChaptersHelper.Copy(this, targetChapters, progressDelegate);
 }
Exemple #44
0
        /// <summary>
        /// Copies to.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="progressDelegate">The progress delegate.</param>
        /// <remarks>Documented by Dev03, 2009-04-19</remarks>
        public void CopyTo(ICopy target, CopyToProgress progressDelegate)
        {
            CopyBase.Copy(this, target, typeof(ICard), progressDelegate);

            //copy media objects
            ICard targetCard = target as ICard;
            if (targetCard != null)
            {
                foreach (IMedia media in QuestionMedia)
                    try
                    {
                        targetCard.AddMedia(media, Side.Question);
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex, "DbCard.AddMedia() throws an exception.");
                    }
                foreach (IMedia media in AnswerMedia)
                    try
                    {
                        targetCard.AddMedia(media, Side.Answer);
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex, "DbCard.AddMedia() throws an exception.");
                    }
            }
        }
Exemple #45
0
        /// <summary>
        /// Copies to.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="progressDelegate">The progress delegate.</param>
        /// <remarks>Documented by Dev03, 2009-03-23</remarks>
        public void CopyTo(ICopy target, CopyToProgress progressDelegate)
        {
            CopyBase.Copy(this, target, typeof(ICard), progressDelegate);

            //copy media objects
            ICard targetCard = target as ICard;
            if (targetCard != null)
            {
                foreach (IMedia media in QuestionMedia)
                    targetCard.AddMedia(media, Side.Question);
                foreach (IMedia media in AnswerMedia)
                    targetCard.AddMedia(media, Side.Answer);
            }
        }
Exemple #46
0
        private void ReplaceSelectedZone(IZone ReplaceZone, ICopy CopyParams)
        {
            IZone zone = worldmap.GetSelectedZone();
            if (zone == null)
                return;

            if (ReplaceZone != null)
                worldmap.ReplaceSelectedZone(ReplaceZone, CopyParams);
        }
Exemple #47
0
 /// <summary>
 /// Copies this instance to the specified target.
 /// </summary>
 /// <param name="target">The target.</param>
 /// <param name="progressDelegate">The progress delegate.</param>
 public void CopyTo(ICopy target, CopyToProgress progressDelegate)
 {
     throw new NotImplementedException();
 }
Exemple #48
0
        public void ReplaceSelectedZone(IZone zone, ICopy ICopyParams)
        {
            int x = SelectedZone.X;
            int y = SelectedZone.Y;

            IZone copyzone = zone.Clone();

            if (ICopyParams is Copy)
            {
                Copy CopyParams = (Copy)ICopyParams;
                IExtZone ExtSelectedZone = (IExtZone)SelectedZone;
                IExtZone ExtCopyZone = (IExtZone)copyzone;

                if (CopyParams.CopyDifficulty)
                    ExtSelectedZone.Difficulty = ExtCopyZone.Difficulty;
                if (CopyParams.CopyGroups)
                {
                    if (CopyParams.Overwrite)
                        ExtSelectedZone.EncounterGroups = ExtCopyZone.EncounterGroups;
                    else
                    {
                        ExtSelectedZone.EncounterGroups.AddRange(ExtCopyZone.EncounterGroups);
                        ExtSelectedZone.EncounterGroups = Utils.RemoveDuplicates<EncounterZoneGroup>(ExtSelectedZone.EncounterGroups);
                    }
                }
                if (CopyParams.CopyLocations)
                {
                    if (CopyParams.Overwrite)
                        ExtSelectedZone.EncounterLocations = ExtCopyZone.EncounterLocations;
                    else
                    {
                        ExtSelectedZone.EncounterLocations.AddRange(ExtCopyZone.EncounterLocations);
                        ExtSelectedZone.EncounterLocations = Utils.RemoveDuplicates<EncounterZoneLocation>(ExtCopyZone.EncounterLocations);
                    }
                }

                if (ExtSelectedZone.EncounterGroups == null)
                    ExtSelectedZone.EncounterGroups = new List<EncounterZoneGroup>();
                if (ExtSelectedZone.EncounterLocations == null)
                    ExtSelectedZone.EncounterLocations = new List<EncounterZoneLocation>();
            }

            if (ICopyParams.CopyTerrain)
                SelectedZone.Terrain = copyzone.Terrain;
            if (ICopyParams.CopyChance)
                SelectedZone.Chance = copyzone.Chance;

            SelectedZone.Brushed = copyzone.Brushed;
            SelectedZone.X = x;
            SelectedZone.Y = y;

            SaveSelected();
        }
Exemple #49
0
 /// <summary>
 /// Copies this instance to the specified target.
 /// </summary>
 /// <param name="target">The target.</param>
 /// <param name="progressDelegate">The progress delegate.</param>
 public void CopyTo(ICopy target, CopyToProgress progressDelegate)
 {
     CardsHelper.Copy(this, target as ICards, progressDelegate);
 }
Exemple #50
0
 private void copyingToolStripMenuItem_Click(object sender, EventArgs e)
 {
     SettingsCopying.ShowDialog();
     ICopyParams = SettingsCopying.ICopyObj;
 }
        /// <summary>
        /// Copies to.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="progressDelegate">The progress delegate.</param>
        /// <remarks>Documented by Dev03, 2009-01-13</remarks>
        public void CopyTo(ICopy target, CopyToProgress progressDelegate)
        {
            CopyBase.Copy(this, target, typeof(IDictionary), progressDelegate);

            //copy extensions
            foreach (IExtension extension in Extensions)
            {
                IExtension newExtension = ((IDictionary)target).ExtensionFactory(extension.Id);
                extension.CopyTo(newExtension, progressDelegate);
            }
        }
Exemple #52
0
 /// <summary>
 /// Copies to.
 /// </summary>
 /// <param name="target">The target.</param>
 /// <param name="progressDelegate">The progress delegate.</param>
 /// <remarks>Documented by Dev03, 2009-01-13</remarks>
 public void CopyTo(ICopy target, CopyToProgress progressDelegate)
 {
     CopyBase.Copy(this, target, typeof(ITextStyle), progressDelegate);
 }