Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions ThirdLesson/Messenger.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2041
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Messenger", "Messenger\Messenger.csproj", "{540DA987-1B8D-4642-9B88-CDFE2352C18C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{540DA987-1B8D-4642-9B88-CDFE2352C18C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{540DA987-1B8D-4642-9B88-CDFE2352C18C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{540DA987-1B8D-4642-9B88-CDFE2352C18C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{540DA987-1B8D-4642-9B88-CDFE2352C18C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {98225E3B-48F5-4430-A131-AD4A924FC5D9}
EndGlobalSection
EndGlobal
27 changes: 27 additions & 0 deletions ThirdLesson/Messenger/Channel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Messenger
{
public class Channel : Myrialog
{
public string Name { get; private set; }

public Channel (string name, List<Message> messages, List<User> users, Dictionary<User, bool> admins, Guid id)
:base(messages, users, admins, false, id)
{
Name = name;
}

public Channel (string name, User Master)
: base(false, new Guid())
{
Users.Add(Master);
Admins.Add(Master, true);
Name = name;
}
}
}
26 changes: 26 additions & 0 deletions ThirdLesson/Messenger/Chat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Messenger
{
public class Chat : Myrialog
{
public Chat(List<Message> messages, List<User> users, Dictionary<User, bool> admins, Guid id)
: base(messages, users, admins, true, id)
{

}

public Chat(User first, User second)
: base(true, new Guid())
{
Users.Add(first);
Admins.Add(first, false);
Users.Add(second);
Admins.Add(second, false);
}
}
}
27 changes: 27 additions & 0 deletions ThirdLesson/Messenger/Group.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Messenger
{
public class Group : Myrialog
{
public string Name { get; private set; }

public Group(string name, List<Message> messages, List<User> users, Dictionary<User, bool> admins, Guid id)
: base(messages, users, admins, true, id)
{
Name = name;
}

public Group(string name, User Master)
: base(true, new Guid())
{
Users.Add(Master);
Admins.Add(Master, true);
Name = name;
}
}
}
24 changes: 24 additions & 0 deletions ThirdLesson/Messenger/Message.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Messenger
{
public class Message
{
public User Author { get; }
public string Text { get; set; }
public DateTimeOffset Date { get; }
public Guid Id { get; }

public Message(User author, string text, DateTimeOffset date, Guid id)
{
Author = author;
Text = text;
Date = date;
Id = id;
}
}
}
53 changes: 53 additions & 0 deletions ThirdLesson/Messenger/Messenger.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{540DA987-1B8D-4642-9B88-CDFE2352C18C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Messenger</RootNamespace>
<AssemblyName>Messenger</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Channel.cs" />
<Compile Include="Chat.cs" />
<Compile Include="Group.cs" />
<Compile Include="Message.cs" />
<Compile Include="Myrialog.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="User.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
93 changes: 93 additions & 0 deletions ThirdLesson/Messenger/Myrialog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Messenger
{
public class Myrialog
{
public List<Message> Messages { get; set; }
public List<User> Users { get; set; }
public Dictionary<User, bool> Admins { get; set; }
public bool AbleToAdd { get; }
public Guid Id { get; }

public bool AddUser(User Master, User ToAdd)
{
if (!Admins[Master]) return false;
else
{
Users.Add(ToAdd);
Admins.Add(ToAdd, false);
return true;
}
}

public bool AddAdmin(User Master, User ToAdd)
{
if ((Admins[Master]) && (Users.Contains(ToAdd))){
Admins[ToAdd] = true;
return true;
}else
return false;
}

public bool AddMesage(User Master, Message ToAdd)
{
if ((Admins[Master]) || (AbleToAdd))
{
Messages.Add(ToAdd);
return true;
}
else return false;
}

public bool DeleteMessage(User Master, Guid MessageId)
{
for (int i = 0; i < Messages.Count; i++)
{
if ((Messages[i].Id == MessageId) && ((Admins[Master]) || (Messages[i].Author == Master)))
{
Messages.RemoveAt(i);
return true;
}
}

return false;
}

public bool EditMessage(User Master, Guid MessageId, string NewText)
{
for (int i = 0; i < Messages.Count; i++)
{
if ((Messages[i].Id == MessageId) && (Messages[i].Author == Master))
{
Messages[i].Text = NewText;
return true;
}
}

return false;
}

public Myrialog(List<Message> messages, List<User> users, Dictionary<User, bool> admins, bool ableToAdd, Guid id)
{
Messages = messages;
Users = users;
Admins = admins;
AbleToAdd = ableToAdd;
Id = id;
}

public Myrialog(bool ableToAdd, Guid id)
{
Messages = new List<Message>();
Users = new List<User>();
Admins = new Dictionary<User, bool>();
AbleToAdd = ableToAdd;
Id = id;
}
}
}
36 changes: 36 additions & 0 deletions ThirdLesson/Messenger/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// Общие сведения об этой сборке предоставляются следующим набором
// набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения,
// связанные со сборкой.
[assembly: AssemblyTitle("Messenger")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Messenger")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
// COM, задайте атрибуту ComVisible значение TRUE для этого типа.
[assembly: ComVisible(false)]

// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
[assembly: Guid("540da987-1b8d-4642-9b88-cdfe2352c18c")]

// Сведения о версии сборки состоят из следующих четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер сборки
// Редакция
//
// Можно задать все значения или принять номер сборки и номер редакции по умолчанию.
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
20 changes: 20 additions & 0 deletions ThirdLesson/Messenger/User.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Messenger
{
public class User
{
public string Name { get; }
public Guid Id { get; }

public User(string name, Guid id)
{
Name = name;
Id = id;
}
}
}
Binary file added ThirdLesson/Messenger/bin/Debug/Messenger.dll
Binary file not shown.
Binary file added ThirdLesson/Messenger/bin/Debug/Messenger.pdb
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f8ec3abc22431a6f48128bf894e858240bc3862a
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
C:\Users\markp\Desktop\Programming\C#\League\Messenger\Messenger\bin\Debug\Messenger.dll
C:\Users\markp\Desktop\Programming\C#\League\Messenger\Messenger\bin\Debug\Messenger.pdb
C:\Users\markp\Desktop\Programming\C#\League\Messenger\Messenger\obj\Debug\Messenger.csprojAssemblyReference.cache
C:\Users\markp\Desktop\Programming\C#\League\Messenger\Messenger\obj\Debug\Messenger.csproj.CoreCompileInputs.cache
C:\Users\markp\Desktop\Programming\C#\League\Messenger\Messenger\obj\Debug\Messenger.dll
C:\Users\markp\Desktop\Programming\C#\League\Messenger\Messenger\obj\Debug\Messenger.pdb
Binary file not shown.
Binary file added ThirdLesson/Messenger/obj/Debug/Messenger.dll
Binary file not shown.
Binary file added ThirdLesson/Messenger/obj/Debug/Messenger.pdb
Binary file not shown.
2 changes: 1 addition & 1 deletion ThirdLesson/readme.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Third lesson of Margelov Vitaly
Third lesson of Vishnevsky Mark